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

/* Variables and functions */
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ log2file(char *, ...);
int /*<<< orphan*/ pclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *popen(char *, char *);
int /*<<< orphan*/ sprintf(char *, char *, char *, ...);
void runProcess(char *packageName, char *serviceName) {
  FILE *fp;
  char service_name[1024];
  sprintf(service_name, "%s/%s", packageName, serviceName);
  char command[1024];
  sprintf(command, "am startservice --user 0 -n %s", service_name);
  log2file("run cmd: %s\n", command);
  if ((fp = popen(command, "r")) == NULL) {
    log2file("popen failed\n");
    exit(1);
  }
  pclose(fp);
}


x86 assembly (clang, -O0):
<runProcess>:
push   %rbp
mov    %rsp,%rbp
sub    $0x820,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x420(%rbp),%rdi
mov    -0x8(%rbp),%rdx
mov    -0x10(%rbp),%rcx
lea    0xe87(%rip),%rsi
mov    $0x0,%al
call   1060 <sprintf@plt>
lea    -0x820(%rbp),%rdi
lea    -0x420(%rbp),%rdx
lea    0xe71(%rip),%rsi
mov    $0x0,%al
call   1060 <sprintf@plt>
lea    -0x820(%rbp),%rsi
lea    0xe7b(%rip),%rdi
mov    $0x0,%al
call   1040 <log2file@plt>
lea    -0x820(%rbp),%rdi
lea    0xe73(%rip),%rsi
call   1050 <popen@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    11ea <runProcess+0x9a>
lea    0xe5b(%rip),%rdi
mov    $0x0,%al
call   1040 <log2file@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
mov    -0x18(%rbp),%rdi
call   1030 <pclose@plt>
add    $0x820,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<runProcess>:
push   %r14
push   %rbx
sub    $0x808,%rsp
mov    %rsi,%rcx
mov    %rdi,%rdx
lea    0xe99(%rip),%rsi
lea    0x400(%rsp),%r14
mov    %r14,%rdi
xor    %eax,%eax
call   1060 <sprintf@plt>
lea    0xe86(%rip),%rsi
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    %r14,%rdx
xor    %eax,%eax
call   1060 <sprintf@plt>
lea    0xe8e(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <log2file@plt>
lea    0xe8a(%rip),%rsi
mov    %rbx,%rdi
call   1050 <popen@plt>
test   %rax,%rax
je     11c8 <runProcess+0x78>
mov    %rax,%rdi
call   1030 <pclose@plt>
add    $0x808,%rsp
pop    %rbx
pop    %r14
ret
lea    0xe65(%rip),%rdi
xor    %eax,%eax
call   1040 <log2file@plt>
mov    $0x1,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@.str = [6 x i8] c"%s/%s\00"
@.str.1 = [31 x i8] c"am startservice --user 0 -n %s\00"
@.str.2 = [13 x i8] c"run cmd: %s\0A\00"
@.str.3 = [2 x i8] c"r\00"
@.str.4 = [14 x i8] c"popen failed\0A\00"
define void @runProcess(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32*
%6 = alloca [1024 x i8]
%7 = alloca [1024 x i8]
store i8* %0, i8** %3
store i8* %1, i8** %4
%8 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%9 = load i8*, i8** %3
%10 = load i8*, i8** %4
%11 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %8, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %9, i8* %10)
%12 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%13 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%14 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %12, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0), i8* %13)
%15 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%16 = call i32 (i8*, ...) @log2file(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i8* %15)
%17 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%18 = call i32* @popen(i8* %17, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32* %18, i32** %5
%19 = icmp eq i32* %18, null
br i1 %19, label %20, label %23
20: ; preds = %2
%21 = call i32 (i8*, ...) @log2file(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0))
%22 = call i32 @exit(i32 1)
unreachable
23: ; preds = %2
%24 = load i32*, i32** %5
%25 = call i32 @pclose(i32* %24)
ret void
}

LLVM IR (-O2):
@.str = [6 x i8] c"%s/%s\00"
@.str.1 = [31 x i8] c"am startservice --user 0 -n %s\00"
@.str.2 = [13 x i8] c"run cmd: %s\0A\00"
@.str.3 = [2 x i8] c"r\00"
@.str.4 = [14 x i8] c"popen failed\0A\00"
define void @runProcess(i8* %0, i8* %1) {
%3 = alloca [1024 x i8]
%4 = alloca [1024 x i8]
%5 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%6 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %5, i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %0, i8* %1)
%7 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%8 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %7, i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0), i8* %5)
%9 = call i32 (i8*, ...) @log2file(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i8* %7)
%10 = call i32* @popen(i8* %7, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%11 = icmp eq i32* %10, null
br i1 %11, label %12, label %15
12: ; preds = %2
%13 = call i32 (i8*, ...) @log2file(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0))
%14 = call i32 @exit(i32 1)
unreachable
15: ; preds = %2
%16 = call i32 @pclose(i32* %10)
ret void
}