#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 */

/* Variables and functions */
int /*<<< orphan*/ sprintf(char *, char *, char const *const, ...);
int system(char *);
void launchWithSystemCall(const char *const app) {
  if (!app)
    return;
  char scriptCode[256];
  sprintf(scriptCode,
          "tell application \\\"%s\\\" to run\n                         tell "
          "application \\\"%s\\\" to activate",
          app, app);
  char commandLine[256];
  sprintf(commandLine, "osascript -e \"%s\"", scriptCode);
  int result = system(commandLine);
}


x86 assembly (clang, -O0):
<launchWithSystemCall>:
push   %rbp
mov    %rsp,%rbp
sub    $0x220,%rsp
mov    %rdi,-0x8(%rbp)
cmpq   $0x0,-0x8(%rbp)
jne    113f <launchWithSystemCall+0x1f>
jmp    118a <launchWithSystemCall+0x6a>
lea    -0x110(%rbp),%rdi
mov    -0x8(%rbp),%rdx
mov    -0x8(%rbp),%rcx
lea    0xeab(%rip),%rsi
mov    $0x0,%al
call   1040 <sprintf@plt>
lea    -0x210(%rbp),%rdi
lea    -0x110(%rbp),%rdx
lea    0xeeb(%rip),%rsi
mov    $0x0,%al
call   1040 <sprintf@plt>
lea    -0x210(%rbp),%rdi
call   1030 <system@plt>
mov    %eax,-0x214(%rbp)
add    $0x220,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<launchWithSystemCall>:
test   %rdi,%rdi
je     1177 <launchWithSystemCall+0x57>
push   %r14
push   %rbx
sub    $0x208,%rsp
mov    %rdi,%rcx
lea    0xec7(%rip),%rsi
lea    0x100(%rsp),%r14
mov    %r14,%rdi
mov    %rcx,%rdx
xor    %eax,%eax
call   1040 <sprintf@plt>
lea    0xf07(%rip),%rsi
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    %r14,%rdx
xor    %eax,%eax
call   1040 <sprintf@plt>
mov    %rbx,%rdi
call   1030 <system@plt>
add    $0x208,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [92 x i8] c"tell application \\\22%s\\\22 to run\0A tell application \\\22%s\\\22 to activate\00"
@.str.1 = [18 x i8] c"osascript -e \22%s\22\00"
define void @launchWithSystemCall(i8* %0) {
%2 = alloca i8*
%3 = alloca [256 x i8]
%4 = alloca [256 x i8]
%5 = alloca i32
store i8* %0, i8** %2
%6 = load i8*, i8** %2
%7 = icmp ne i8* %6, null
br i1 %7, label %9, label %8
8: ; preds = %1
br label %19
9: ; preds = %1
%10 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%11 = load i8*, i8** %2
%12 = load i8*, i8** %2
%13 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %10, i8* getelementptr inbounds ([92 x i8], [92 x i8]* @.str, i64 0, i64 0), i8* %11, i8* %12)
%14 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 0
%15 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%16 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %14, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i8* %15)
%17 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 0
%18 = call i32 @system(i8* %17)
store i32 %18, i32* %5
br label %19
19: ; preds = %9, %8
ret void
}

LLVM IR (-O2):
@.str = [92 x i8] c"tell application \\\22%s\\\22 to run\0A tell application \\\22%s\\\22 to activate\00"
@.str.1 = [18 x i8] c"osascript -e \22%s\22\00"
define void @launchWithSystemCall(i8* %0) {
%2 = alloca [256 x i8]
%3 = alloca [256 x i8]
%4 = icmp eq i8* %0, null
br i1 %4, label %11, label %5
5: ; preds = %1
%6 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
%7 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %6, i8* dereferenceable(1) getelementptr inbounds ([92 x i8], [92 x i8]* @.str, i64 0, i64 0), i8* %0, i8* %0)
%8 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%9 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %8, i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i8* %6)
%10 = call i32 @system(i8* %8)
br label %11
11: ; preds = %1, %5
ret void
}