#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*/ fget(char *, int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ sprintf(char *, char *, char *, char *);
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ system(char *);
int ipswDownloader() {
  char model[10];
  char choice1[10];
  char version[7];
  char link[1024];
  char rep2[3];
  char firmware[80];
  printf("Download firmware ?\n");
  printf("1) YES\n");
  printf("2) NO\n");
  fget(choice1, 10);
  if (strcmp(choice1, "yes") == 0 || strcmp(choice1, "1") == 0) {
    printf("Model : ");
    fget(model, 10);
    printf("Version : ");
    fget(version, 7);
    printf("The firmware will be automaticaly extracted\n");
    printf("Downloading IPSW, please wait...\n");
    sprintf(link, "wget http://api.ipsw.me/v2/%s/%s/url/dl -O firmware.ipsw",
            model, version);
    system(link);
    system("bin\\7z.exe x -oIPSW firmware.ipsw");
    return 0;
  } else if (strcmp(choice1, "no") == 0 || strcmp(choice1, "2") == 0) {
    printf("\n");
  }
  return 0;
}


x86 assembly (clang, -O0):
<ipswDownloader>:
push   %rbp
mov    %rsp,%rbp
sub    $0x480,%rsp
lea    0xe9e(%rip),%rdi
call   1040 <printf@plt>
lea    0xea7(%rip),%rdi
call   1040 <printf@plt>
lea    0xea3(%rip),%rdi
call   1040 <printf@plt>
lea    -0x18(%rbp),%rdi
mov    $0xa,%esi
call   1050 <fget@plt>
lea    -0x18(%rbp),%rdi
lea    0xe8c(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
je     11c1 <ipswDownloader+0x71>
lea    -0x18(%rbp),%rdi
lea    0xe76(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
jne    124c <ipswDownloader+0xfc>
lea    0xe62(%rip),%rdi
call   1040 <printf@plt>
lea    -0xe(%rbp),%rdi
mov    $0xa,%esi
call   1050 <fget@plt>
lea    0xe51(%rip),%rdi
call   1040 <printf@plt>
lea    -0x1f(%rbp),%rdi
mov    $0x7,%esi
call   1050 <fget@plt>
lea    0xe42(%rip),%rdi
call   1040 <printf@plt>
lea    0xe63(%rip),%rdi
call   1040 <printf@plt>
lea    -0x420(%rbp),%rdi
lea    -0xe(%rbp),%rdx
lea    -0x1f(%rbp),%rcx
lea    0xe6a(%rip),%rsi
call   1070 <sprintf@plt>
lea    -0x420(%rbp),%rdi
call   1030 <system@plt>
lea    0xe8b(%rip),%rdi
call   1030 <system@plt>
movl   $0x0,-0x4(%rbp)
jmp    1298 <ipswDownloader+0x148>
lea    -0x18(%rbp),%rdi
lea    0xe91(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
je     1280 <ipswDownloader+0x130>
lea    -0x18(%rbp),%rdi
lea    0xe7a(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
jne    128c <ipswDownloader+0x13c>
lea    0xe04(%rip),%rdi
call   1040 <printf@plt>
jmp    1291 <ipswDownloader+0x141>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x480,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ipswDownloader>:
push   %r15
push   %r14
push   %rbx
sub    $0x420,%rsp
lea    0xef7(%rip),%rdi
call   1040 <puts@plt>
lea    0xeff(%rip),%rdi
call   1040 <puts@plt>
lea    0xefa(%rip),%rdi
call   1040 <puts@plt>
lea    0x5(%rsp),%rbx
mov    %rbx,%rdi
mov    $0xa,%esi
call   1070 <fget@plt>
lea    0xe47(%rip),%rsi
mov    %rbx,%rdi
call   1080 <strcmp@plt>
test   %rax,%rax
je     121b <ipswDownloader+0xab>
lea    0xe37(%rip),%rsi
lea    0x5(%rsp),%rdi
call   1080 <strcmp@plt>
test   %rax,%rax
je     121b <ipswDownloader+0xab>
lea    0xe92(%rip),%rsi
lea    0x5(%rsp),%rdi
call   1080 <strcmp@plt>
test   %rax,%rax
je     120c <ipswDownloader+0x9c>
lea    0xe7f(%rip),%rsi
lea    0x5(%rsp),%rdi
call   1080 <strcmp@plt>
test   %rax,%rax
jne    129d <ipswDownloader+0x12d>
mov    $0xa,%edi
call   1030 <putchar@plt>
jmp    129d <ipswDownloader+0x12d>
lea    0xde4(%rip),%rdi
call   1060 <printf@plt>
lea    0x16(%rsp),%r14
mov    %r14,%rdi
mov    $0xa,%esi
call   1070 <fget@plt>
lea    0xdcf(%rip),%rdi
call   1060 <printf@plt>
lea    0xf(%rsp),%r15
mov    %r15,%rdi
mov    $0x7,%esi
call   1070 <fget@plt>
lea    0xe3d(%rip),%rdi
call   1040 <puts@plt>
lea    0xe5d(%rip),%rdi
call   1040 <puts@plt>
lea    0xda4(%rip),%rsi
lea    0x20(%rsp),%rbx
mov    %rbx,%rdi
mov    %r14,%rdx
mov    %r15,%rcx
call   1090 <sprintf@plt>
mov    %rbx,%rdi
call   1050 <system@plt>
lea    0xdbb(%rip),%rdi
call   1050 <system@plt>
xor    %eax,%eax
add    $0x420,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [21 x i8] c"Download firmware ?\0A\00"
@.str.1 = [8 x i8] c"1) YES\0A\00"
@.str.2 = [7 x i8] c"2) NO\0A\00"
@.str.3 = [4 x i8] c"yes\00"
@.str.4 = [2 x i8] c"1\00"
@.str.5 = [9 x i8] c"Model : \00"
@.str.6 = [11 x i8] c"Version : \00"
@.str.7 = [45 x i8] c"The firmware will be automaticaly extracted\0A\00"
@.str.8 = [34 x i8] c"Downloading IPSW, please wait...\0A\00"
@.str.9 = [57 x i8] c"wget http://api.ipsw.me/v2/%s/%s/url/dl -O firmware.ipsw\00"
@.str.10 = [34 x i8] c"bin\\7z.exe x -oIPSW firmware.ipsw\00"
@.str.11 = [3 x i8] c"no\00"
@.str.12 = [2 x i8] c"2\00"
@.str.13 = [2 x i8] c"\0A\00"
define i32 @ipswDownloader() {
%1 = alloca i32
%2 = alloca [10 x i8]
%3 = alloca [10 x i8]
%4 = alloca [7 x i8]
%5 = alloca [1024 x i8]
%6 = alloca [3 x i8]
%7 = alloca [80 x i8]
%8 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
%9 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%10 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
%11 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 0
%12 = call i32 @fget(i8* %11, i32 10)
%13 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 0
%14 = call i64 @strcmp(i8* %13, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
%15 = icmp eq i64 %14, 0
br i1 %15, label %20, label %16
16: ; preds = %0
%17 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 0
%18 = call i64 @strcmp(i8* %17, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%19 = icmp eq i64 %18, 0
br i1 %19, label %20, label %36
20: ; preds = %16, %0
%21 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0))
%22 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 0
%23 = call i32 @fget(i8* %22, i32 10)
%24 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.6, i64 0, i64 0))
%25 = getelementptr inbounds [7 x i8], [7 x i8]* %4, i64 0, i64 0
%26 = call i32 @fget(i8* %25, i32 7)
%27 = call i32 @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.7, i64 0, i64 0))
%28 = call i32 @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.8, i64 0, i64 0))
%29 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%30 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 0
%31 = getelementptr inbounds [7 x i8], [7 x i8]* %4, i64 0, i64 0
%32 = call i32 @sprintf(i8* %29, i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str.9, i64 0, i64 0), i8* %30, i8* %31)
%33 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%34 = call i32 @system(i8* %33)
%35 = call i32 @system(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.10, i64 0, i64 0))
store i32 0, i32* %1
br label %48
36: ; preds = %16
%37 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 0
%38 = call i64 @strcmp(i8* %37, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.11, i64 0, i64 0))
%39 = icmp eq i64 %38, 0
br i1 %39, label %44, label %40
40: ; preds = %36
%41 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 0
%42 = call i64 @strcmp(i8* %41, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.12, i64 0, i64 0))
%43 = icmp eq i64 %42, 0
br i1 %43, label %44, label %46
44: ; preds = %40, %36
%45 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.13, i64 0, i64 0))
br label %46
46: ; preds = %44, %40
br label %47
47: ; preds = %46
store i32 0, i32* %1
br label %48
48: ; preds = %47, %20
%49 = load i32, i32* %1
ret i32 %49
}

LLVM IR (-O2):
@.str.3 = [4 x i8] c"yes\00"
@.str.4 = [2 x i8] c"1\00"
@.str.5 = [9 x i8] c"Model : \00"
@.str.6 = [11 x i8] c"Version : \00"
@.str.9 = [57 x i8] c"wget http://api.ipsw.me/v2/%s/%s/url/dl -O firmware.ipsw\00"
@.str.10 = [34 x i8] c"bin\\7z.exe x -oIPSW firmware.ipsw\00"
@.str.11 = [3 x i8] c"no\00"
@.str.12 = [2 x i8] c"2\00"
@str = [20 x i8] c"Download firmware ?\00"
@str.14 = [7 x i8] c"1) YES\00"
@str.15 = [6 x i8] c"2) NO\00"
@str.16 = [44 x i8] c"The firmware will be automaticaly extracted\00"
@str.17 = [33 x i8] c"Downloading IPSW, please wait...\00"
define i32 @ipswDownloader() {
%1 = alloca [10 x i8]
%2 = alloca [10 x i8]
%3 = alloca [7 x i8]
%4 = alloca [1024 x i8]
%5 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 0
%6 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 0
%7 = getelementptr inbounds [7 x i8], [7 x i8]* %3, i64 0, i64 0
%8 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str, i64 0, i64 0))
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @str.14, i64 0, i64 0))
%11 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @str.15, i64 0, i64 0))
%12 = call i32 @fget(i8* %6, i32 10)
%13 = call i64 @strcmp(i8* %6, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
%14 = icmp eq i64 %13, 0
br i1 %14, label %18, label %15
15: ; preds = %0
%16 = call i64 @strcmp(i8* %6, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%17 = icmp eq i64 %16, 0
br i1 %17, label %18, label %28
18: ; preds = %15, %0
%19 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0))
%20 = call i32 @fget(i8* %5, i32 10)
%21 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.6, i64 0, i64 0))
%22 = call i32 @fget(i8* %7, i32 7)
%23 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @str.16, i64 0, i64 0))
%24 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @str.17, i64 0, i64 0))
%25 = call i32 @sprintf(i8* %8, i8* dereferenceable(1) getelementptr inbounds ([57 x i8], [57 x i8]* @.str.9, i64 0, i64 0), i8* %5, i8* %7)
%26 = call i32 @system(i8* %8)
%27 = call i32 @system(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.10, i64 0, i64 0))
br label %36
28: ; preds = %15
%29 = call i64 @strcmp(i8* %6, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.11, i64 0, i64 0))
%30 = icmp eq i64 %29, 0
br i1 %30, label %34, label %31
31: ; preds = %28
%32 = call i64 @strcmp(i8* %6, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.12, i64 0, i64 0))
%33 = icmp eq i64 %32, 0
br i1 %33, label %34, label %36
34: ; preds = %31, %28
%35 = call i32 @putchar(i32 10)
br label %36
36: ; preds = %34, %31, %18
ret i32 0
}