#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*/ buffer;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int EXIT_SUCCESS;
scalar_t__ fread(char *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ memset(char *, char, int);
int /*<<< orphan*/ *popen(char *, char *);
int /*<<< orphan*/ printf(char *, char *);
int main(int argc, char **argv) {
  FILE *pf;
  char buffer[4096];
  pf = popen("gradle build -p /home/huibin/android/project/SnailIM", "r");
  while (fread(buffer, sizeof(buffer), 1, pf)) {
    printf("%s\n", buffer);
  }
  printf("%s\n", "BUILD SUCCESSFUL");
  memset(buffer, '\0', sizeof(buffer));
  pf = popen("adb uninstall com.snail.im", "r");
  while (fread(buffer, sizeof(buffer), 1, pf)) {
    printf("%s\n", buffer);
  }
  printf("%s\n", "APK UNINSTALL SUCCESSFUL");
  pf = popen("adb install "
             "/home/huibin/android/project/SnailIM/IM/build/apk/"
             "IM-playstore-release.apk",
             "r");
  while (fread(buffer, sizeof(buffer), 1, pf)) {
    printf("%s\n", buffer);
  }
  printf("%s\n", "APK INSTALL SUCCESSFUL");
  printf("%s\n", "---complete---");
  return (EXIT_SUCCESS);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1020,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xea0(%rip),%rdi
lea    0xece(%rip),%rsi
call   1060 <popen@plt>
mov    %rax,-0x18(%rbp)
lea    -0x1020(%rbp),%rdi
mov    -0x18(%rbp),%rcx
mov    $0x1000,%esi
mov    $0x1,%edx
call   1030 <fread@plt>
cmp    $0x0,%rax
je     11ac <main+0x6c>
lea    -0x1020(%rbp),%rsi
lea    0xe95(%rip),%rdi
call   1040 <printf@plt>
jmp    1170 <main+0x30>
lea    0xe84(%rip),%rdi
lea    0xe81(%rip),%rsi
call   1040 <printf@plt>
lea    -0x1020(%rbp),%rdi
xor    %esi,%esi
mov    $0x1000,%edx
call   1050 <memset@plt>
lea    0xe73(%rip),%rdi
lea    0xe55(%rip),%rsi
call   1060 <popen@plt>
mov    %rax,-0x18(%rbp)
lea    -0x1020(%rbp),%rdi
mov    -0x18(%rbp),%rcx
mov    $0x1000,%esi
mov    $0x1,%edx
call   1030 <fread@plt>
cmp    $0x0,%rax
je     1225 <main+0xe5>
lea    -0x1020(%rbp),%rsi
lea    0xe1c(%rip),%rdi
call   1040 <printf@plt>
jmp    11e9 <main+0xa9>
lea    0xe0b(%rip),%rdi
lea    0xe34(%rip),%rsi
call   1040 <printf@plt>
lea    0xe41(%rip),%rdi
lea    0xdef(%rip),%rsi
call   1060 <popen@plt>
mov    %rax,-0x18(%rbp)
lea    -0x1020(%rbp),%rdi
mov    -0x18(%rbp),%rcx
mov    $0x1000,%esi
mov    $0x1,%edx
call   1030 <fread@plt>
cmp    $0x0,%rax
je     128b <main+0x14b>
lea    -0x1020(%rbp),%rsi
lea    0xdb6(%rip),%rdi
call   1040 <printf@plt>
jmp    124f <main+0x10f>
lea    0xda5(%rip),%rdi
lea    0xe3e(%rip),%rsi
call   1040 <printf@plt>
lea    0xd92(%rip),%rdi
lea    0xe42(%rip),%rsi
call   1040 <printf@plt>
mov    0x2d28(%rip),%rax
mov    (%rax),%eax
add    $0x1020,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x1000,%rsp
lea    0xead(%rip),%rdi
lea    0xedb(%rip),%rsi
call   1060 <popen@plt>
mov    %rax,%r15
mov    %rsp,%rdi
mov    $0x1000,%esi
mov    $0x1,%edx
mov    %rax,%rcx
call   1030 <fread@plt>
test   %rax,%rax
je     11b5 <main+0x75>
lea    0xeb4(%rip),%r14
mov    %rsp,%rbx
cs nopw 0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    %rbx,%rsi
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    $0x1000,%esi
mov    $0x1,%edx
mov    %r15,%rcx
call   1030 <fread@plt>
test   %rax,%rax
jne    1190 <main+0x50>
lea    0xe7b(%rip),%rdi
lea    0xe78(%rip),%rsi
call   1040 <printf@plt>
mov    %rsp,%rbx
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x1000,%edx
call   1050 <memset@plt>
lea    0xe6b(%rip),%rdi
lea    0xe4d(%rip),%rsi
call   1060 <popen@plt>
mov    %rax,%r15
mov    %rbx,%rdi
mov    $0x1000,%esi
mov    $0x1,%edx
mov    %rax,%rcx
call   1030 <fread@plt>
test   %rax,%rax
je     1245 <main+0x105>
lea    0xe26(%rip),%r14
mov    %rsp,%rbx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r14,%rdi
mov    %rbx,%rsi
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    $0x1000,%esi
mov    $0x1,%edx
mov    %r15,%rcx
call   1030 <fread@plt>
test   %rax,%rax
jne    1220 <main+0xe0>
lea    0xdeb(%rip),%rdi
lea    0xe14(%rip),%rsi
call   1040 <printf@plt>
lea    0xe21(%rip),%rdi
lea    0xdcf(%rip),%rsi
call   1060 <popen@plt>
mov    %rax,%r15
mov    %rsp,%rdi
mov    $0x1000,%esi
mov    $0x1,%edx
mov    %rax,%rcx
call   1030 <fread@plt>
test   %rax,%rax
je     12c5 <main+0x185>
lea    0xda8(%rip),%r14
mov    %rsp,%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r14,%rdi
mov    %rbx,%rsi
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    $0x1000,%esi
mov    $0x1,%edx
mov    %r15,%rcx
call   1030 <fread@plt>
test   %rax,%rax
jne    12a0 <main+0x160>
lea    0xd6b(%rip),%rbx
lea    0xe04(%rip),%rsi
mov    %rbx,%rdi
call   1040 <printf@plt>
lea    0xe0c(%rip),%rsi
mov    %rbx,%rdi
call   1040 <printf@plt>
mov    0x2cef(%rip),%rax
mov    (%rax),%eax
add    $0x1000,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [53 x i8] c"gradle build -p /home/huibin/android/project/SnailIM\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [4 x i8] c"%s\0A\00"
@.str.3 = [17 x i8] c"BUILD SUCCESSFUL\00"
@.str.4 = [27 x i8] c"adb uninstall com.snail.im\00"
@.str.5 = [25 x i8] c"APK UNINSTALL SUCCESSFUL\00"
@.str.6 = [87 x i8] c"adb install /home/huibin/android/project/SnailIM/IM/build/apk/IM-playstore-release.apk\00"
@.str.7 = [23 x i8] c"APK INSTALL SUCCESSFUL\00"
@.str.8 = [15 x i8] c"---complete---\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca [4096 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = call i32* @popen(i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %8, i32** %6
br label %9
9: ; preds = %14, %2
%10 = getelementptr inbounds [4096 x i8], [4096 x i8]* %7, i64 0, i64 0
%11 = load i32*, i32** %6
%12 = call i64 @fread(i8* %10, i32 4096, i32 1, i32* %11)
%13 = icmp ne i64 %12, 0
br i1 %13, label %14, label %17
14: ; preds = %9
%15 = getelementptr inbounds [4096 x i8], [4096 x i8]* %7, i64 0, i64 0
%16 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %15)
br label %9
17: ; preds = %9
%18 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0))
%19 = getelementptr inbounds [4096 x i8], [4096 x i8]* %7, i64 0, i64 0
%20 = call i32 @memset(i8* %19, i8 signext 0, i32 4096)
%21 = call i32* @popen(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %21, i32** %6
br label %22
22: ; preds = %27, %17
%23 = getelementptr inbounds [4096 x i8], [4096 x i8]* %7, i64 0, i64 0
%24 = load i32*, i32** %6
%25 = call i64 @fread(i8* %23, i32 4096, i32 1, i32* %24)
%26 = icmp ne i64 %25, 0
br i1 %26, label %27, label %30
27: ; preds = %22
%28 = getelementptr inbounds [4096 x i8], [4096 x i8]* %7, i64 0, i64 0
%29 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %28)
br label %22
30: ; preds = %22
%31 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.5, i64 0, i64 0))
%32 = call i32* @popen(i8* getelementptr inbounds ([87 x i8], [87 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %32, i32** %6
br label %33
33: ; preds = %38, %30
%34 = getelementptr inbounds [4096 x i8], [4096 x i8]* %7, i64 0, i64 0
%35 = load i32*, i32** %6
%36 = call i64 @fread(i8* %34, i32 4096, i32 1, i32* %35)
%37 = icmp ne i64 %36, 0
br i1 %37, label %38, label %41
38: ; preds = %33
%39 = getelementptr inbounds [4096 x i8], [4096 x i8]* %7, i64 0, i64 0
%40 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %39)
br label %33
41: ; preds = %33
%42 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.7, i64 0, i64 0))
%43 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.8, i64 0, i64 0))
%44 = load i32, i32* @EXIT_SUCCESS
ret i32 %44
}

LLVM IR (-O2):
@.str = [53 x i8] c"gradle build -p /home/huibin/android/project/SnailIM\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [4 x i8] c"%s\0A\00"
@.str.3 = [17 x i8] c"BUILD SUCCESSFUL\00"
@.str.4 = [27 x i8] c"adb uninstall com.snail.im\00"
@.str.5 = [25 x i8] c"APK UNINSTALL SUCCESSFUL\00"
@.str.6 = [87 x i8] c"adb install /home/huibin/android/project/SnailIM/IM/build/apk/IM-playstore-release.apk\00"
@.str.7 = [23 x i8] c"APK INSTALL SUCCESSFUL\00"
@.str.8 = [15 x i8] c"---complete---\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [4096 x i8]
%4 = getelementptr inbounds [4096 x i8], [4096 x i8]* %3, i64 0, i64 0
%5 = tail call i32* @popen(i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%6 = call i64 @fread(i8* %4, i32 4096, i32 1, i32* %5)
%7 = icmp eq i64 %6, 0
br i1 %7, label %12, label %8
8: ; preds = %2, %8
%9 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %4)
%10 = call i64 @fread(i8* %4, i32 4096, i32 1, i32* %5)
%11 = icmp eq i64 %10, 0
br i1 %11, label %12, label %8
12: ; preds = %8, %2
%13 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0))
%14 = call i32 @memset(i8* %4, i8 signext 0, i32 4096)
%15 = call i32* @popen(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%16 = call i64 @fread(i8* %4, i32 4096, i32 1, i32* %15)
%17 = icmp eq i64 %16, 0
br i1 %17, label %22, label %18
18: ; preds = %12, %18
%19 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %4)
%20 = call i64 @fread(i8* %4, i32 4096, i32 1, i32* %15)
%21 = icmp eq i64 %20, 0
br i1 %21, label %22, label %18
22: ; preds = %18, %12
%23 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.5, i64 0, i64 0))
%24 = call i32* @popen(i8* getelementptr inbounds ([87 x i8], [87 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%25 = call i64 @fread(i8* %4, i32 4096, i32 1, i32* %24)
%26 = icmp eq i64 %25, 0
br i1 %26, label %31, label %27
27: ; preds = %22, %27
%28 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %4)
%29 = call i64 @fread(i8* %4, i32 4096, i32 1, i32* %24)
%30 = icmp eq i64 %29, 0
br i1 %30, label %31, label %27
31: ; preds = %27, %22
%32 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.7, i64 0, i64 0))
%33 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.8, i64 0, i64 0))
%34 = load i32, i32* @EXIT_SUCCESS
ret i32 %34
}