#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*/ exit(int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ rpi_car_backward();
int /*<<< orphan*/ rpi_car_dev_close(int);
int rpi_car_dev_open();
char *rpi_car_dev_version();
int /*<<< orphan*/ rpi_car_forward();
int /*<<< orphan*/ rpi_car_left();
int /*<<< orphan*/ rpi_car_stop();
int /*<<< orphan*/ usleep(int);
int main(int argc, char *argv[]) {
  printf("### Device Test - Start ###\n");
  int dev = rpi_car_dev_open();
  if (dev < 0) {
    printf("Device open failed, rval = %d\n", dev);
    exit(1);
  } else {
    printf("Device open succeeded.\n");
  }
  char *version = rpi_car_dev_version();
  if (version != NULL) {
    printf("Device firmware version: %s\n", version);
  } else {
    printf("Device get version failed.\n");
    exit(2);
  }
  printf("### Device Test - Stop ###\n");
  printf("### Servo Test - Start ###\n");
  rpi_car_stop();
  usleep(10000000);
  rpi_car_forward();
  usleep(10000000);
  rpi_car_backward();
  usleep(10000000);
  rpi_car_left();
  usleep(10000000);
  rpi_car_forward();
  usleep(10000000);
  rpi_car_backward();
  usleep(10000000);
  rpi_car_stop();
  printf("### Servo Test - Stop ###\n");
  rpi_car_dev_close(dev);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xe43(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    $0x0,%al
call   1090 <rpi_car_dev_open@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jge    11f3 <main+0x53>
mov    -0x14(%rbp),%esi
lea    0xe3b(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    $0x1,%edi
call   10a0 <exit@plt>
lea    0xe42(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    $0x0,%al
call   1080 <rpi_car_dev_version@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     122e <main+0x8e>
mov    -0x20(%rbp),%rsi
lea    0xe32(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    1246 <main+0xa6>
lea    0xe3c(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    $0x2,%edi
call   10a0 <exit@plt>
lea    0xe40(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xe4e(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    $0x0,%al
call   10b0 <rpi_car_stop@plt>
mov    $0x989680,%edi
call   10c0 <usleep@plt>
mov    $0x0,%al
call   1050 <rpi_car_forward@plt>
mov    $0x989680,%edi
call   10c0 <usleep@plt>
mov    $0x0,%al
call   1030 <rpi_car_backward@plt>
mov    $0x989680,%edi
call   10c0 <usleep@plt>
mov    $0x0,%al
call   1070 <rpi_car_left@plt>
mov    $0x989680,%edi
call   10c0 <usleep@plt>
mov    $0x0,%al
call   1050 <rpi_car_forward@plt>
mov    $0x989680,%edi
call   10c0 <usleep@plt>
mov    $0x0,%al
call   1030 <rpi_car_backward@plt>
mov    $0x989680,%edi
call   10c0 <usleep@plt>
mov    $0x0,%al
call   10b0 <rpi_car_stop@plt>
lea    0xdef(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x14(%rbp),%edi
call   1040 <rpi_car_dev_close@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
lea    0xe84(%rip),%rdi
call   1060 <puts@plt>
xor    %eax,%eax
call   10a0 <rpi_car_dev_open@plt>
mov    %eax,%ebx
test   %eax,%eax
js     1297 <main+0xe7>
lea    0xe83(%rip),%rdi
call   1060 <puts@plt>
xor    %eax,%eax
call   1090 <rpi_car_dev_version@plt>
test   %rax,%rax
je     12b1 <main+0x101>
lea    0xe2e(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1070 <printf@plt>
lea    0xe88(%rip),%rdi
call   1060 <puts@plt>
lea    0xe97(%rip),%rdi
call   1060 <puts@plt>
xor    %eax,%eax
call   10c0 <rpi_car_stop@plt>
mov    $0x989680,%edi
call   10d0 <usleep@plt>
xor    %eax,%eax
call   1050 <rpi_car_forward@plt>
mov    $0x989680,%edi
call   10d0 <usleep@plt>
xor    %eax,%eax
call   1030 <rpi_car_backward@plt>
mov    $0x989680,%edi
call   10d0 <usleep@plt>
xor    %eax,%eax
call   1080 <rpi_car_left@plt>
mov    $0x989680,%edi
call   10d0 <usleep@plt>
xor    %eax,%eax
call   1050 <rpi_car_forward@plt>
mov    $0x989680,%edi
call   10d0 <usleep@plt>
xor    %eax,%eax
call   1030 <rpi_car_backward@plt>
mov    $0x989680,%edi
call   10d0 <usleep@plt>
xor    %eax,%eax
call   10c0 <rpi_car_stop@plt>
lea    0xe39(%rip),%rdi
call   1060 <puts@plt>
mov    %ebx,%edi
call   1040 <rpi_car_dev_close@plt>
xor    %eax,%eax
pop    %rbx
ret
lea    0xd62(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1070 <printf@plt>
mov    $0x1,%edi
call   10b0 <exit@plt>
lea    0xdb7(%rip),%rdi
call   1060 <puts@plt>
mov    $0x2,%edi
call   10b0 <exit@plt>

LLVM IR (-O0):
@.str = [29 x i8] c"### Device Test - Start ###\0A\00"
@.str.1 = [31 x i8] c"Device open failed, rval = %d\0A\00"
@.str.2 = [24 x i8] c"Device open succeeded.\0A\00"
@.str.3 = [29 x i8] c"Device firmware version: %s\0A\00"
@.str.4 = [28 x i8] c"Device get version failed.\0A\00"
@.str.5 = [28 x i8] c"### Device Test - Stop ###\0A\00"
@.str.6 = [28 x i8] c"### Servo Test - Start ###\0A\00"
@.str.7 = [27 x i8] c"### Servo Test - Stop ###\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
%9 = call i32 (...) @rpi_car_dev_open()
store i32 %9, i32* %6
%10 = load i32, i32* %6
%11 = icmp slt i32 %10, 0
br i1 %11, label %12, label %16
12: ; preds = %2
%13 = load i32, i32* %6
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0), i32 %13)
%15 = call i32 @exit(i32 1)
unreachable
16: ; preds = %2
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0))
br label %18
18: ; preds = %16
%19 = call i8* (...) @rpi_car_dev_version()
store i8* %19, i8** %7
%20 = load i8*, i8** %7
%21 = icmp ne i8* %20, null
br i1 %21, label %22, label %25
22: ; preds = %18
%23 = load i8*, i8** %7
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.3, i64 0, i64 0), i8* %23)
br label %28
25: ; preds = %18
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.4, i64 0, i64 0))
%27 = call i32 @exit(i32 2)
unreachable
28: ; preds = %22
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.5, i64 0, i64 0))
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.6, i64 0, i64 0))
%31 = call i32 (...) @rpi_car_stop()
%32 = call i32 @usleep(i32 10000000)
%33 = call i32 (...) @rpi_car_forward()
%34 = call i32 @usleep(i32 10000000)
%35 = call i32 (...) @rpi_car_backward()
%36 = call i32 @usleep(i32 10000000)
%37 = call i32 (...) @rpi_car_left()
%38 = call i32 @usleep(i32 10000000)
%39 = call i32 (...) @rpi_car_forward()
%40 = call i32 @usleep(i32 10000000)
%41 = call i32 (...) @rpi_car_backward()
%42 = call i32 @usleep(i32 10000000)
%43 = call i32 (...) @rpi_car_stop()
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.7, i64 0, i64 0))
%45 = load i32, i32* %6
%46 = call i32 @rpi_car_dev_close(i32 %45)
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [31 x i8] c"Device open failed, rval = %d\0A\00"
@.str.3 = [29 x i8] c"Device firmware version: %s\0A\00"
@str = [28 x i8] c"### Device Test - Start ###\00"
@str.8 = [23 x i8] c"Device open succeeded.\00"
@str.9 = [27 x i8] c"Device get version failed.\00"
@str.10 = [27 x i8] c"### Device Test - Stop ###\00"
@str.11 = [27 x i8] c"### Servo Test - Start ###\00"
@str.12 = [26 x i8] c"### Servo Test - Stop ###\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @str, i64 0, i64 0))
%4 = tail call i32 (...) @rpi_car_dev_open()
%5 = icmp slt i32 %4, 0
br i1 %5, label %6, label %9
6: ; preds = %2
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0), i32 %4)
%8 = tail call i32 @exit(i32 1)
unreachable
9: ; preds = %2
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str.8, i64 0, i64 0))
%11 = tail call i8* (...) @rpi_car_dev_version()
%12 = icmp eq i8* %11, null
br i1 %12, label %32, label %13
13: ; preds = %9
%14 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.3, i64 0, i64 0), i8* %11)
%15 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str.10, i64 0, i64 0))
%16 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str.11, i64 0, i64 0))
%17 = tail call i32 (...) @rpi_car_stop()
%18 = tail call i32 @usleep(i32 10000000)
%19 = tail call i32 (...) @rpi_car_forward()
%20 = tail call i32 @usleep(i32 10000000)
%21 = tail call i32 (...) @rpi_car_backward()
%22 = tail call i32 @usleep(i32 10000000)
%23 = tail call i32 (...) @rpi_car_left()
%24 = tail call i32 @usleep(i32 10000000)
%25 = tail call i32 (...) @rpi_car_forward()
%26 = tail call i32 @usleep(i32 10000000)
%27 = tail call i32 (...) @rpi_car_backward()
%28 = tail call i32 @usleep(i32 10000000)
%29 = tail call i32 (...) @rpi_car_stop()
%30 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str.12, i64 0, i64 0))
%31 = tail call i32 @rpi_car_dev_close(i32 %4)
ret i32 0
32: ; preds = %9
%33 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str.9, i64 0, i64 0))
%34 = tail call i32 @exit(i32 2)
unreachable
}