#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 EXIT_SUCCESS;
int /*<<< orphan*/ fget(char *, int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ sprintf(char *, char *, char *);
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ system(char *);
int idevicecrashreport() {
  char choice[80];
  char path[1024];
  char buildCommand[1024];
  system("clear");
  printf("1) Extract raw crash report into separate '.crash' file\n");
  printf("2) Copy but do not remove crash reports from device\n");
  fget(choice, 80);
  if (strcmp(choice, "extract") == 0 || strcmp(choice, "1") == 0) {
    printf("Enter the directory to copy the file : ");
    fget(path, 1024);
    sprintf(buildCommand, "idevicecrashreport -e %s", path);
    system(buildCommand);
  }
  if (strcmp(choice, "copy") == 0 || strcmp(choice, "2") == 0) {
    printf("Enter the directory to copy the file : ");
    fget(path, 1024);
    sprintf(buildCommand, "idevicecrashreport -k %s", path);
    system(buildCommand);
  }
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<idevicecrashreport>:
push   %rbp
mov    %rsp,%rbp
sub    $0x850,%rsp
lea    0xe9e(%rip),%rdi
call   1030 <system@plt>
lea    0xe98(%rip),%rdi
call   1040 <printf@plt>
lea    0xec5(%rip),%rdi
call   1040 <printf@plt>
lea    -0x50(%rbp),%rdi
mov    $0x50,%esi
call   1050 <fget@plt>
lea    -0x50(%rbp),%rdi
lea    0xedc(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
je     11c1 <idevicecrashreport+0x71>
lea    -0x50(%rbp),%rdi
lea    0xeca(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
jne    1204 <idevicecrashreport+0xb4>
lea    0xeb6(%rip),%rdi
call   1040 <printf@plt>
lea    -0x450(%rbp),%rdi
mov    $0x400,%esi
call   1050 <fget@plt>
lea    -0x850(%rbp),%rdi
lea    -0x450(%rbp),%rdx
lea    0xeb3(%rip),%rsi
call   1070 <sprintf@plt>
lea    -0x850(%rbp),%rdi
call   1030 <system@plt>
lea    -0x50(%rbp),%rdi
lea    0xeb0(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
je     1238 <idevicecrashreport+0xe8>
lea    -0x50(%rbp),%rdi
lea    0xe9b(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
jne    127b <idevicecrashreport+0x12b>
lea    0xe3f(%rip),%rdi
call   1040 <printf@plt>
lea    -0x450(%rbp),%rdi
mov    $0x400,%esi
call   1050 <fget@plt>
lea    -0x850(%rbp),%rdi
lea    -0x450(%rbp),%rdx
lea    0xe5c(%rip),%rsi
call   1070 <sprintf@plt>
lea    -0x850(%rbp),%rdi
call   1030 <system@plt>
mov    0x2d5e(%rip),%rax
mov    (%rax),%eax
add    $0x850,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<idevicecrashreport>:
push   %r14
push   %rbx
sub    $0x858,%rsp
lea    0xe8f(%rip),%rdi
call   1040 <system@plt>
lea    0xef4(%rip),%rdi
call   1030 <puts@plt>
lea    0xf20(%rip),%rdi
call   1030 <puts@plt>
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0x50,%esi
call   1060 <fget@plt>
lea    0xe61(%rip),%rsi
mov    %rbx,%rdi
call   1070 <strcmp@plt>
test   %rax,%rax
je     11c6 <idevicecrashreport+0x66>
lea    0xe55(%rip),%rsi
mov    %rsp,%rdi
call   1070 <strcmp@plt>
test   %rax,%rax
jne    1206 <idevicecrashreport+0xa6>
lea    0xe43(%rip),%rdi
call   1050 <printf@plt>
lea    0x450(%rsp),%r14
mov    %r14,%rdi
mov    $0x400,%esi
call   1060 <fget@plt>
lea    0xe4a(%rip),%rsi
lea    0x50(%rsp),%rbx
mov    %rbx,%rdi
mov    %r14,%rdx
call   1080 <sprintf@plt>
mov    %rbx,%rdi
call   1040 <system@plt>
lea    0xe44(%rip),%rsi
mov    %rsp,%rdi
call   1070 <strcmp@plt>
test   %rax,%rax
je     122e <idevicecrashreport+0xce>
lea    0xe35(%rip),%rsi
mov    %rsp,%rdi
call   1070 <strcmp@plt>
test   %rax,%rax
jne    126e <idevicecrashreport+0x10e>
lea    0xddb(%rip),%rdi
call   1050 <printf@plt>
lea    0x450(%rsp),%r14
mov    %r14,%rdi
mov    $0x400,%esi
call   1060 <fget@plt>
lea    0xe02(%rip),%rsi
lea    0x50(%rsp),%rbx
mov    %rbx,%rdi
mov    %r14,%rdx
call   1080 <sprintf@plt>
mov    %rbx,%rdi
call   1040 <system@plt>
mov    0x2d6b(%rip),%rax
mov    (%rax),%eax
add    $0x858,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [6 x i8] c"clear\00"
@.str.1 = [57 x i8] c"1) Extract raw crash report into separate '.crash' file\0A\00"
@.str.2 = [53 x i8] c"2) Copy but do not remove crash reports from device\0A\00"
@.str.3 = [8 x i8] c"extract\00"
@.str.4 = [2 x i8] c"1\00"
@.str.5 = [40 x i8] c"Enter the directory to copy the file : \00"
@.str.6 = [25 x i8] c"idevicecrashreport -e %s\00"
@.str.7 = [5 x i8] c"copy\00"
@.str.8 = [2 x i8] c"2\00"
@.str.9 = [25 x i8] c"idevicecrashreport -k %s\00"
@EXIT_SUCCESS = global i32 0
define i32 @idevicecrashreport() {
%1 = alloca [80 x i8]
%2 = alloca [1024 x i8]
%3 = alloca [1024 x i8]
%4 = call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%5 = call i32 @printf(i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str.1, i64 0, i64 0))
%6 = call i32 @printf(i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.2, i64 0, i64 0))
%7 = getelementptr inbounds [80 x i8], [80 x i8]* %1, i64 0, i64 0
%8 = call i32 @fget(i8* %7, i32 80)
%9 = getelementptr inbounds [80 x i8], [80 x i8]* %1, i64 0, i64 0
%10 = call i64 @strcmp(i8* %9, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0))
%11 = icmp eq i64 %10, 0
br i1 %11, label %16, label %12
12: ; preds = %0
%13 = getelementptr inbounds [80 x i8], [80 x i8]* %1, i64 0, i64 0
%14 = call i64 @strcmp(i8* %13, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%15 = icmp eq i64 %14, 0
br i1 %15, label %16, label %25
16: ; preds = %12, %0
%17 = call i32 @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.5, i64 0, i64 0))
%18 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%19 = call i32 @fget(i8* %18, i32 1024)
%20 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%21 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%22 = call i32 @sprintf(i8* %20, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.6, i64 0, i64 0), i8* %21)
%23 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%24 = call i32 @system(i8* %23)
br label %25
25: ; preds = %16, %12
%26 = getelementptr inbounds [80 x i8], [80 x i8]* %1, i64 0, i64 0
%27 = call i64 @strcmp(i8* %26, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0))
%28 = icmp eq i64 %27, 0
br i1 %28, label %33, label %29
29: ; preds = %25
%30 = getelementptr inbounds [80 x i8], [80 x i8]* %1, i64 0, i64 0
%31 = call i64 @strcmp(i8* %30, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0))
%32 = icmp eq i64 %31, 0
br i1 %32, label %33, label %42
33: ; preds = %29, %25
%34 = call i32 @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.5, i64 0, i64 0))
%35 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%36 = call i32 @fget(i8* %35, i32 1024)
%37 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%38 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%39 = call i32 @sprintf(i8* %37, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.9, i64 0, i64 0), i8* %38)
%40 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%41 = call i32 @system(i8* %40)
br label %42
42: ; preds = %33, %29
%43 = load i32, i32* @EXIT_SUCCESS
ret i32 %43
}

LLVM IR (-O2):
@.str = [6 x i8] c"clear\00"
@.str.3 = [8 x i8] c"extract\00"
@.str.4 = [2 x i8] c"1\00"
@.str.5 = [40 x i8] c"Enter the directory to copy the file : \00"
@.str.6 = [25 x i8] c"idevicecrashreport -e %s\00"
@.str.7 = [5 x i8] c"copy\00"
@.str.8 = [2 x i8] c"2\00"
@.str.9 = [25 x i8] c"idevicecrashreport -k %s\00"
@EXIT_SUCCESS = global i32 0
@str = [56 x i8] c"1) Extract raw crash report into separate '.crash' file\00"
@str.10 = [52 x i8] c"2) Copy but do not remove crash reports from device\00"
define i32 @idevicecrashreport() {
%1 = alloca [80 x i8]
%2 = alloca [1024 x i8]
%3 = alloca [1024 x i8]
%4 = getelementptr inbounds [80 x i8], [80 x i8]* %1, i64 0, i64 0
%5 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%6 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%7 = tail call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([56 x i8], [56 x i8]* @str, i64 0, i64 0))
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([52 x i8], [52 x i8]* @str.10, i64 0, i64 0))
%10 = call i32 @fget(i8* %4, i32 80)
%11 = call i64 @strcmp(i8* %4, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0))
%12 = icmp eq i64 %11, 0
br i1 %12, label %16, label %13
13: ; preds = %0
%14 = call i64 @strcmp(i8* %4, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%15 = icmp eq i64 %14, 0
br i1 %15, label %16, label %21
16: ; preds = %13, %0
%17 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @.str.5, i64 0, i64 0))
%18 = call i32 @fget(i8* %5, i32 1024)
%19 = call i32 @sprintf(i8* %6, i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.6, i64 0, i64 0), i8* %5)
%20 = call i32 @system(i8* %6)
br label %21
21: ; preds = %16, %13
%22 = call i64 @strcmp(i8* %4, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0))
%23 = icmp eq i64 %22, 0
br i1 %23, label %27, label %24
24: ; preds = %21
%25 = call i64 @strcmp(i8* %4, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0))
%26 = icmp eq i64 %25, 0
br i1 %26, label %27, label %32
27: ; preds = %24, %21
%28 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @.str.5, i64 0, i64 0))
%29 = call i32 @fget(i8* %5, i32 1024)
%30 = call i32 @sprintf(i8* %6, i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.9, i64 0, i64 0), i8* %5)
%31 = call i32 @system(i8* %6)
br label %32
32: ; preds = %27, %24
%33 = load i32, i32* @EXIT_SUCCESS
ret i32 %33
}