#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 */
scalar_t__ chAccessoryMode(char *, char *, char *, char *, char *, char *);
int /*<<< orphan*/ closeHandle();
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ init();
scalar_t__ open_accesory_dev();
int /*<<< orphan*/ stdout;
int main(int argc, char *argv[]) {
  init();
  if (open_accesory_dev() < 0)
    return 0;
  fprintf(stdout, "Start setting up accessory\n");
  if (chAccessoryMode("bols", "Demo", "Description", "1.0",
                      "http://market.android.com/"
                      "search?q=jp.co.topgate.android.game.gree.sengoku",
                      "2hhh254711SerialNhho.") < 0) {
    fprintf(stdout, "Error setting up accessory\n");
    closeHandle();
    return -1;
  };
  fprintf(stdout, "end setup\n");
  closeHandle();
  fprintf(stdout, "Done, no errors\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x0,%al
call   1050 <init@plt>
mov    $0x0,%al
call   1070 <open_accesory_dev@plt>
cmp    $0x0,%rax
jge    118a <main+0x3a>
movl   $0x0,-0x4(%rbp)
jmp    1238 <main+0xe8>
mov    0x2e4f(%rip),%rax
mov    (%rax),%edi
lea    0xe66(%rip),%rsi
call   1040 <fprintf@plt>
lea    0xe76(%rip),%rdi
lea    0xe74(%rip),%rsi
lea    0xe72(%rip),%rdx
lea    0xe77(%rip),%rcx
lea    0xe74(%rip),%r8
lea    0xeb8(%rip),%r9
call   1060 <chAccessoryMode@plt>
cmp    $0x0,%rax
jge    1200 <main+0xb0>
mov    0x2e01(%rip),%rax
mov    (%rax),%edi
lea    0xeaf(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0x0,%al
call   1030 <closeHandle@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1238 <main+0xe8>
mov    0x2dd9(%rip),%rax
mov    (%rax),%edi
lea    0xea3(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0x0,%al
call   1030 <closeHandle@plt>
mov    0x2dbd(%rip),%rax
mov    (%rax),%edi
lea    0xe92(%rip),%rsi
call   1040 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
xor    %ebx,%ebx
xor    %eax,%eax
call   1050 <init@plt>
xor    %eax,%eax
call   1070 <open_accesory_dev@plt>
test   %rax,%rax
js     11f8 <main+0xa8>
mov    0x2e6c(%rip),%r14
mov    (%r14),%edi
lea    0xe82(%rip),%rsi
call   1040 <fprintf@plt>
lea    0xe92(%rip),%rdi
lea    0xe90(%rip),%rsi
lea    0xe8e(%rip),%rdx
lea    0xe93(%rip),%rcx
lea    0xe90(%rip),%r8
lea    0xed4(%rip),%r9
call   1060 <chAccessoryMode@plt>
mov    (%r14),%edi
test   %rax,%rax
js     11e0 <main+0x90>
lea    0xef2(%rip),%rsi
call   1040 <fprintf@plt>
xor    %ebx,%ebx
xor    %eax,%eax
call   1030 <closeHandle@plt>
mov    (%r14),%edi
lea    0xee5(%rip),%rsi
call   1040 <fprintf@plt>
jmp    11f8 <main+0xa8>
lea    0xeb0(%rip),%rsi
call   1040 <fprintf@plt>
xor    %eax,%eax
call   1030 <closeHandle@plt>
mov    $0xffffffff,%ebx
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@stdout = global i32 0
@.str = [28 x i8] c"Start setting up accessory\0A\00"
@.str.1 = [5 x i8] c"bols\00"
@.str.2 = [5 x i8] c"Demo\00"
@.str.3 = [12 x i8] c"Description\00"
@.str.4 = [4 x i8] c"1.0\00"
@.str.5 = [75 x i8] c"http://market.android.com/search?q=jp.co.topgate.android.game.gree.sengoku\00"
@.str.6 = [22 x i8] c"2hhh254711SerialNhho.\00"
@.str.7 = [28 x i8] c"Error setting up accessory\0A\00"
@.str.8 = [11 x i8] c"end setup\0A\00"
@.str.9 = [17 x i8] c"Done, no errors\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%6 = call i32 (...) @init()
%7 = call i64 (...) @open_accesory_dev()
%8 = icmp slt i64 %7, 0
br i1 %8, label %9, label %10
9: ; preds = %2
store i32 0, i32* %3
br label %25
10: ; preds = %2
%11 = load i32, i32* @stdout
%12 = call i32 @fprintf(i32 %11, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0))
%13 = call i64 @chAccessoryMode(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([75 x i8], [75 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.6, i64 0, i64 0))
%14 = icmp slt i64 %13, 0
br i1 %14, label %15, label %19
15: ; preds = %10
%16 = load i32, i32* @stdout
%17 = call i32 @fprintf(i32 %16, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.7, i64 0, i64 0))
%18 = call i32 (...) @closeHandle()
store i32 -1, i32* %3
br label %25
19: ; preds = %10
%20 = load i32, i32* @stdout
%21 = call i32 @fprintf(i32 %20, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.8, i64 0, i64 0))
%22 = call i32 (...) @closeHandle()
%23 = load i32, i32* @stdout
%24 = call i32 @fprintf(i32 %23, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.9, i64 0, i64 0))
store i32 0, i32* %3
br label %25
25: ; preds = %19, %15, %9
%26 = load i32, i32* %3
ret i32 %26
}

LLVM IR (-O2):
@stdout = global i32 0
@.str = [28 x i8] c"Start setting up accessory\0A\00"
@.str.1 = [5 x i8] c"bols\00"
@.str.2 = [5 x i8] c"Demo\00"
@.str.3 = [12 x i8] c"Description\00"
@.str.4 = [4 x i8] c"1.0\00"
@.str.5 = [75 x i8] c"http://market.android.com/search?q=jp.co.topgate.android.game.gree.sengoku\00"
@.str.6 = [22 x i8] c"2hhh254711SerialNhho.\00"
@.str.7 = [28 x i8] c"Error setting up accessory\0A\00"
@.str.8 = [11 x i8] c"end setup\0A\00"
@.str.9 = [17 x i8] c"Done, no errors\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i32 (...) @init()
%4 = tail call i64 (...) @open_accesory_dev()
%5 = icmp slt i64 %4, 0
br i1 %5, label %20, label %6
6: ; preds = %2
%7 = load i32, i32* @stdout
%8 = tail call i32 @fprintf(i32 %7, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0))
%9 = tail call i64 @chAccessoryMode(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([75 x i8], [75 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.6, i64 0, i64 0))
%10 = icmp slt i64 %9, 0
%11 = load i32, i32* @stdout
br i1 %10, label %12, label %15
12: ; preds = %6
%13 = tail call i32 @fprintf(i32 %11, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.7, i64 0, i64 0))
%14 = tail call i32 (...) @closeHandle()
br label %20
15: ; preds = %6
%16 = tail call i32 @fprintf(i32 %11, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.8, i64 0, i64 0))
%17 = tail call i32 (...) @closeHandle()
%18 = load i32, i32* @stdout
%19 = tail call i32 @fprintf(i32 %18, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.9, i64 0, i64 0))
br label %20
20: ; preds = %2, %15, %12
%21 = phi i32 [ -1, %12 ], [ 0, %15 ], [ 0, %2 ]
ret i32 %21
}