#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*/ printf(char *, ...);
int /*<<< orphan*/ propulsion_ifce_close();
int propulsion_ifce_fire(int, int, int, int);
int propulsion_ifce_open();
int /*<<< orphan*/ sleep(int);
int main(int argc, const char *argv[]) {
  int fd;
  int rc = 0;
  int i;
  printf("propulsion_ifce"
         ": opening thruster devices...\n");
  fd = propulsion_ifce_open();
  if (fd < 0) {
    printf("propulsion_ifce"
           ".main: "
           "error while opening... %8X\n",
           fd);
    return 99;
  }
  for (i = 0; i < 15; i++) {
    printf("propulsion_ifce"
           ".main: "
           "firing thrusters...800, 800, -500, -500\n");
    rc = propulsion_ifce_fire(800, 800, -500, -500);
    if (rc) {
      printf("propulsion_ifce"
             ".main: "
             "error firing thrusters.  %8.8X\n",
             rc);
      return rc;
    }
    sleep(1);
    printf("propulsion_ifce"
           ".main: "
           "firing thrusters...-800, -800, 100, 100\n");
    rc = propulsion_ifce_fire(-800, -800, 100, 100);
    if (rc) {
      printf("propulsion_ifce"
             ".main: "
             "error firing thrusters.  %8.8X\n",
             rc);
      return rc;
    }
    sleep(1);
  }
  printf("propulsion_ifce"
         ".main: "
         "closing thruster device...\n");
  propulsion_ifce_close();
  return rc;
}


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)
movl   $0x0,-0x18(%rbp)
lea    0xe8c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x0,%al
call   1030 <propulsion_ifce_open@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jge    11ac <main+0x5c>
mov    -0x14(%rbp),%esi
lea    0xe95(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x63,-0x4(%rbp)
jmp    128e <main+0x13e>
movl   $0x0,-0x1c(%rbp)
cmpl   $0xf,-0x1c(%rbp)
jge    1273 <main+0x123>
lea    0xe9c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x320,%esi
mov    $0xfffffe0c,%ecx
mov    %esi,%edi
mov    %ecx,%edx
call   1060 <propulsion_ifce_fire@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
je     1207 <main+0xb7>
mov    -0x18(%rbp),%esi
lea    0xeaa(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x18(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    128e <main+0x13e>
mov    $0x1,%edi
call   1070 <sleep@plt>
lea    0xebd(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0xfffffce0,%esi
mov    $0x64,%ecx
mov    %esi,%edi
mov    %ecx,%edx
call   1060 <propulsion_ifce_fire@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
je     125b <main+0x10b>
mov    -0x18(%rbp),%esi
lea    0xe56(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x18(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    128e <main+0x13e>
mov    $0x1,%edi
call   1070 <sleep@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11b3 <main+0x63>
lea    0xe9a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x0,%al
call   1050 <propulsion_ifce_close@plt>
mov    -0x18(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
lea    0xefa(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   1040 <propulsion_ifce_open@plt>
test   %eax,%eax
js     122e <main+0xce>
mov    $0xf,%ebx
lea    0xf38(%rip),%r14
lea    0xf6f(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
nop
mov    %r14,%rdi
call   1030 <puts@plt>
mov    $0x320,%edi
mov    $0x320,%esi
mov    $0xfffffe0c,%edx
mov    $0xfffffe0c,%ecx
call   1070 <propulsion_ifce_fire@plt>
test   %eax,%eax
jne    121a <main+0xba>
mov    $0x1,%edi
call   1080 <sleep@plt>
mov    %r15,%rdi
call   1030 <puts@plt>
mov    $0xfffffce0,%edi
mov    $0xfffffce0,%esi
mov    $0x64,%edx
mov    $0x64,%ecx
call   1070 <propulsion_ifce_fire@plt>
test   %eax,%eax
jne    121a <main+0xba>
mov    $0x1,%edi
call   1080 <sleep@plt>
add    $0xffffffff,%ebx
jne    11a0 <main+0x40>
lea    0xe8b(%rip),%rdi
call   1030 <puts@plt>
xor    %ebp,%ebp
xor    %eax,%eax
call   1060 <propulsion_ifce_close@plt>
jmp    1243 <main+0xe3>
mov    %eax,%ebp
lea    0xe0f(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    1243 <main+0xe3>
lea    0xdcb(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0x63,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [46 x i8] c"propulsion_ifce: opening thruster devices...\0A\00"
@.str.1 = [50 x i8] c"propulsion_ifce.main: error while opening... %8X\0A\00"
@.str.2 = [63 x i8] c"propulsion_ifce.main: firing thrusters...800, 800, -500, -500\0A\00"
@.str.3 = [54 x i8] c"propulsion_ifce.main: error firing thrusters. %8.8X\0A\00"
@.str.4 = [63 x i8] c"propulsion_ifce.main: firing thrusters...-800, -800, 100, 100\0A\00"
@.str.5 = [50 x i8] c"propulsion_ifce.main: closing thruster device...\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %7
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str, i64 0, i64 0))
%10 = call i32 (...) @propulsion_ifce_open()
store i32 %10, i32* %6
%11 = load i32, i32* %6
%12 = icmp slt i32 %11, 0
br i1 %12, label %13, label %16
13: ; preds = %2
%14 = load i32, i32* %6
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.1, i64 0, i64 0), i32 %14)
store i32 99, i32* %3
br label %48
16: ; preds = %2
store i32 0, i32* %8
br label %17
17: ; preds = %41, %16
%18 = load i32, i32* %8
%19 = icmp slt i32 %18, 15
br i1 %19, label %20, label %44
20: ; preds = %17
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([63 x i8], [63 x i8]* @.str.2, i64 0, i64 0))
%22 = call i32 @propulsion_ifce_fire(i32 800, i32 800, i32 -500, i32 -500)
store i32 %22, i32* %7
%23 = load i32, i32* %7
%24 = icmp ne i32 %23, 0
br i1 %24, label %25, label %29
25: ; preds = %20
%26 = load i32, i32* %7
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.3, i64 0, i64 0), i32 %26)
%28 = load i32, i32* %7
store i32 %28, i32* %3
br label %48
29: ; preds = %20
%30 = call i32 @sleep(i32 1)
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([63 x i8], [63 x i8]* @.str.4, i64 0, i64 0))
%32 = call i32 @propulsion_ifce_fire(i32 -800, i32 -800, i32 100, i32 100)
store i32 %32, i32* %7
%33 = load i32, i32* %7
%34 = icmp ne i32 %33, 0
br i1 %34, label %35, label %39
35: ; preds = %29
%36 = load i32, i32* %7
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.3, i64 0, i64 0), i32 %36)
%38 = load i32, i32* %7
store i32 %38, i32* %3
br label %48
39: ; preds = %29
%40 = call i32 @sleep(i32 1)
br label %41
41: ; preds = %39
%42 = load i32, i32* %8
%43 = add nsw i32 %42, 1
store i32 %43, i32* %8
br label %17
44: ; preds = %17
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.5, i64 0, i64 0))
%46 = call i32 (...) @propulsion_ifce_close()
%47 = load i32, i32* %7
store i32 %47, i32* %3
br label %48
48: ; preds = %44, %35, %25, %13
%49 = load i32, i32* %3
ret i32 %49
}

LLVM IR (-O2):
@.str.1 = [50 x i8] c"propulsion_ifce.main: error while opening... %8X\0A\00"
@.str.3 = [54 x i8] c"propulsion_ifce.main: error firing thrusters. %8.8X\0A\00"
@str = [45 x i8] c"propulsion_ifce: opening thruster devices...\00"
@str.6 = [49 x i8] c"propulsion_ifce.main: closing thruster device...\00"
@str.7 = [62 x i8] c"propulsion_ifce.main: firing thrusters...800, 800, -500, -500\00"
@str.8 = [62 x i8] c"propulsion_ifce.main: firing thrusters...-800, -800, 100, 100\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @str, i64 0, i64 0))
%4 = tail call i32 (...) @propulsion_ifce_open()
%5 = icmp slt i32 %4, 0
br i1 %5, label %6, label %8
6: ; preds = %2
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([50 x i8], [50 x i8]* @.str.1, i64 0, i64 0), i32 %4)
br label %29
8: ; preds = %2, %22
%9 = phi i32 [ %24, %22 ], [ 0, %2 ]
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([62 x i8], [62 x i8]* @str.7, i64 0, i64 0))
%11 = tail call i32 @propulsion_ifce_fire(i32 800, i32 800, i32 -500, i32 -500)
%12 = icmp eq i32 %11, 0
br i1 %12, label %15, label %13
13: ; preds = %8
%14 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([54 x i8], [54 x i8]* @.str.3, i64 0, i64 0), i32 %11)
br label %29
15: ; preds = %8
%16 = tail call i32 @sleep(i32 1)
%17 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([62 x i8], [62 x i8]* @str.8, i64 0, i64 0))
%18 = tail call i32 @propulsion_ifce_fire(i32 -800, i32 -800, i32 100, i32 100)
%19 = icmp eq i32 %18, 0
br i1 %19, label %22, label %20
20: ; preds = %15
%21 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([54 x i8], [54 x i8]* @.str.3, i64 0, i64 0), i32 %18)
br label %29
22: ; preds = %15
%23 = tail call i32 @sleep(i32 1)
%24 = add nuw nsw i32 %9, 1
%25 = icmp eq i32 %24, 15
br i1 %25, label %26, label %8
26: ; preds = %22
%27 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([49 x i8], [49 x i8]* @str.6, i64 0, i64 0))
%28 = tail call i32 (...) @propulsion_ifce_close()
br label %29
29: ; preds = %26, %20, %13, %6
%30 = phi i32 [ 99, %6 ], [ %11, %13 ], [ %18, %20 ], [ 0, %26 ]
ret i32 %30
}