#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */
typedef int /*<<< orphan*/ buf;

/* Variables and functions */
int /*<<< orphan*/ strcat(char *, char *);
int strlen(char *);
int /*<<< orphan*/ strncpy(char *, char const *, int);
int /*<<< orphan*/ system(char *);
int start_background_program(const char *cmd) {
  char buf[1024];
  {
    strncpy(buf, cmd, sizeof(buf) - strlen(buf) - 1);
    buf[sizeof(buf) - strlen(buf) - 1 - 1] = '\000';
  };
  strcat(buf, " &");
  return !system(buf);
}


x86 assembly (clang, -O0):
<start_background_program>:
push   %rbp
mov    %rsp,%rbp
sub    $0x420,%rsp
mov    %rdi,-0x8(%rbp)
lea    -0x410(%rbp),%rax
mov    %rax,-0x420(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x418(%rbp)
lea    -0x410(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x420(%rbp),%rdi
mov    -0x418(%rbp),%rsi
movslq %eax,%rcx
mov    $0x400,%eax
sub    %rcx,%rax
sub    $0x1,%rax
mov    %eax,%edx
call   1030 <strncpy@plt>
lea    -0x410(%rbp),%rdi
call   1040 <strlen@plt>
movslq %eax,%rcx
mov    $0x400,%eax
sub    %rcx,%rax
sub    $0x1,%rax
sub    $0x1,%rax
movb   $0x0,-0x410(%rbp,%rax,1)
lea    -0x410(%rbp),%rdi
lea    0xe33(%rip),%rsi
call   1060 <strcat@plt>
lea    -0x410(%rbp),%rdi
call   1050 <system@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%eax
add    $0x420,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<start_background_program>:
push   %r14
push   %rbx
sub    $0x408,%rsp
mov    %rdi,%r14
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1040 <strlen@plt>
mov    $0x3ff,%edx
sub    %eax,%edx
mov    %rbx,%rdi
mov    %r14,%rsi
call   1030 <strncpy@plt>
mov    %rbx,%rdi
call   1040 <strlen@plt>
cltq
neg    %rax
movb   $0x0,0x3fe(%rsp,%rax,1)
lea    0xe7a(%rip),%rsi
mov    %rbx,%rdi
call   1060 <strcat@plt>
mov    %rbx,%rdi
call   1050 <system@plt>
xor    %ecx,%ecx
test   %eax,%eax
sete   %cl
mov    %ecx,%eax
add    $0x408,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [3 x i8] c" &\00"
define i32 @start_background_program(i8* %0) {
%2 = alloca i8*
%3 = alloca [1024 x i8]
store i8* %0, i8** %2
%4 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%5 = load i8*, i8** %2
%6 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%7 = call i32 @strlen(i8* %6)
%8 = sext i32 %7 to i64
%9 = sub i64 1024, %8
%10 = sub i64 %9, 1
%11 = trunc i64 %10 to i32
%12 = call i32 @strncpy(i8* %4, i8* %5, i32 %11)
%13 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%14 = call i32 @strlen(i8* %13)
%15 = sext i32 %14 to i64
%16 = sub i64 1024, %15
%17 = sub i64 %16, 1
%18 = sub i64 %17, 1
%19 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 %18
store i8 0, i8* %19
%20 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%21 = call i32 @strcat(i8* %20, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%22 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%23 = call i32 @system(i8* %22)
%24 = icmp ne i32 %23, 0
%25 = xor i1 %24, true
%26 = zext i1 %25 to i32
ret i32 %26
}

LLVM IR (-O2):
@.str = [3 x i8] c" &\00"
define i32 @start_background_program(i8* %0) {
%2 = alloca [1024 x i8]
%3 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%4 = call i32 @strlen(i8* %3)
%5 = sub i32 1023, %4
%6 = call i32 @strncpy(i8* %3, i8* %0, i32 %5)
%7 = call i32 @strlen(i8* %3)
%8 = sext i32 %7 to i64
%9 = sub nsw i64 1022, %8
%10 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 %9
store i8 0, i8* %10
%11 = call i32 @strcat(i8* %3, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%12 = call i32 @system(i8* %3)
%13 = icmp eq i32 %12, 0
%14 = zext i1 %13 to i32
ret i32 %14
}