#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 bcm4751_autobaud(int);
int bcm4751_serial_open();
int /*<<< orphan*/ meif_read_loop(int);
int /*<<< orphan*/ printf(char *);
int sec_gps_power(int);
int main(void) {
  int fd = -1;
  int rc = -1;
  printf("Turning the GPS on...\n");
  rc = sec_gps_power(1);
  if (rc < 0) {
    printf("Failed to turn the GPS on!\n");
    return 1;
  }
  printf("Opening the GPS serial...\n");
  fd = bcm4751_serial_open();
  if (fd < 0) {
    printf("Failed to open the GPS serial!\n");
    return 1;
  }
  printf("Sending autobaud...\n");
  rc = bcm4751_autobaud(fd);
  if (fd < 0) {
    printf("Failed to send autobaud!\n");
    return 1;
  }
  meif_read_loop(fd);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0xffffffff,-0x8(%rbp)
movl   $0xffffffff,-0xc(%rbp)
lea    0xe8c(%rip),%rdi
call   1050 <printf@plt>
mov    $0x1,%edi
call   1040 <sec_gps_power@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jge    11a8 <main+0x58>
lea    0xe80(%rip),%rdi
call   1050 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1228 <main+0xd8>
lea    0xe84(%rip),%rdi
call   1050 <printf@plt>
mov    $0x0,%al
call   1030 <bcm4751_serial_open@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jge    11e0 <main+0x90>
lea    0xe7f(%rip),%rdi
call   1050 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1228 <main+0xd8>
lea    0xe87(%rip),%rdi
call   1050 <printf@plt>
mov    -0x8(%rbp),%edi
call   1060 <bcm4751_autobaud@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0x8(%rbp)
jge    1219 <main+0xc9>
lea    0xe7b(%rip),%rdi
call   1050 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1228 <main+0xd8>
mov    -0x8(%rbp),%edi
call   1070 <meif_read_loop@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
lea    0xea6(%rip),%rdi
call   1040 <puts@plt>
mov    $0x1,%ebx
mov    $0x1,%edi
call   1050 <sec_gps_power@plt>
test   %eax,%eax
js     11a9 <main+0x59>
lea    0xe9d(%rip),%rdi
call   1040 <puts@plt>
xor    %ebx,%ebx
xor    %eax,%eax
call   1030 <bcm4751_serial_open@plt>
test   %eax,%eax
js     11b7 <main+0x67>
mov    %eax,%ebp
lea    0xe9c(%rip),%rdi
call   1040 <puts@plt>
mov    %ebp,%edi
call   1060 <bcm4751_autobaud@plt>
mov    %ebp,%edi
call   1070 <meif_read_loop@plt>
jmp    11c8 <main+0x78>
lea    0xeb3(%rip),%rdi
call   1040 <puts@plt>
jmp    11c8 <main+0x78>
lea    0xe86(%rip),%rdi
call   1040 <puts@plt>
mov    $0x1,%ebx
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [23 x i8] c"Turning the GPS on...\0A\00"
@.str.1 = [28 x i8] c"Failed to turn the GPS on!\0A\00"
@.str.2 = [27 x i8] c"Opening the GPS serial...\0A\00"
@.str.3 = [32 x i8] c"Failed to open the GPS serial!\0A\00"
@.str.4 = [21 x i8] c"Sending autobaud...\0A\00"
@.str.5 = [26 x i8] c"Failed to send autobaud!\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store i32 0, i32* %1
store i32 -1, i32* %2
store i32 -1, i32* %3
%4 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
%5 = call i32 @sec_gps_power(i32 1)
store i32 %5, i32* %3
%6 = load i32, i32* %3
%7 = icmp slt i32 %6, 0
br i1 %7, label %8, label %10
8: ; preds = %0
%9 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0))
store i32 1, i32* %1
br label %28
10: ; preds = %0
%11 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0))
%12 = call i32 (...) @bcm4751_serial_open()
store i32 %12, i32* %2
%13 = load i32, i32* %2
%14 = icmp slt i32 %13, 0
br i1 %14, label %15, label %17
15: ; preds = %10
%16 = call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.3, i64 0, i64 0))
store i32 1, i32* %1
br label %28
17: ; preds = %10
%18 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0))
%19 = load i32, i32* %2
%20 = call i32 @bcm4751_autobaud(i32 %19)
store i32 %20, i32* %3
%21 = load i32, i32* %2
%22 = icmp slt i32 %21, 0
br i1 %22, label %23, label %25
23: ; preds = %17
%24 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.5, i64 0, i64 0))
store i32 1, i32* %1
br label %28
25: ; preds = %17
%26 = load i32, i32* %2
%27 = call i32 @meif_read_loop(i32 %26)
store i32 0, i32* %1
br label %28
28: ; preds = %25, %23, %15, %8
%29 = load i32, i32* %1
ret i32 %29
}

LLVM IR (-O2):
@str = [22 x i8] c"Turning the GPS on...\00"
@str.6 = [26 x i8] c"Opening the GPS serial...\00"
@str.7 = [20 x i8] c"Sending autobaud...\00"
@str.8 = [31 x i8] c"Failed to open the GPS serial!\00"
@str.9 = [27 x i8] c"Failed to turn the GPS on!\00"
define i32 @main() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str, i64 0, i64 0))
%2 = tail call i32 @sec_gps_power(i32 1)
%3 = icmp slt i32 %2, 0
br i1 %3, label %4, label %6
4: ; preds = %0
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str.9, i64 0, i64 0))
br label %16
6: ; preds = %0
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str.6, i64 0, i64 0))
%8 = tail call i32 (...) @bcm4751_serial_open()
%9 = icmp slt i32 %8, 0
br i1 %9, label %10, label %12
10: ; preds = %6
%11 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @str.8, i64 0, i64 0))
br label %16
12: ; preds = %6
%13 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str.7, i64 0, i64 0))
%14 = tail call i32 @bcm4751_autobaud(i32 %8)
%15 = tail call i32 @meif_read_loop(i32 %8)
br label %16
16: ; preds = %12, %10, %4
%17 = phi i32 [ 1, %4 ], [ 1, %10 ], [ 0, %12 ]
ret i32 %17
}