#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*/ B115200;
int EXIT_FAILURE;
int EXIT_SUCCESS;
int /*<<< orphan*/ amrDecode(int);
int /*<<< orphan*/ close(int);
int openSerialPort(char *, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int main(int argc, char **argv) {
  if (argc < 2) {
    printf("Usage: amrpulse [serial port]\n");
    printf("Example: amrpulse /dev/ttyACM0\n");
    return (EXIT_FAILURE);
  }
  int fd = openSerialPort(argv[1], B115200);
  if (fd < 0) {
    printf("Open serial port error (%s)\n", argv[1]);
    return (EXIT_FAILURE);
  }
  for (;;) {
    amrDecode(fd);
  }
  close(fd);
  return (EXIT_SUCCESS);
}


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)
cmpl   $0x2,-0x8(%rbp)
jge    117d <main+0x4d>
lea    0xea9(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xeba(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    0x2e6d(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    11d9 <main+0xa9>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    0x2e4c(%rip),%rax
mov    (%rax),%esi
call   1030 <openSerialPort@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jge    11c7 <main+0x97>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xe90(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    0x2e23(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    11d9 <main+0xa9>
jmp    11cc <main+0x9c>
mov    -0x14(%rbp),%edi
call   1050 <amrDecode@plt>
jmp    11cc <main+0x9c>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
cmp    $0x1,%edi
jg     1162 <main+0x22>
lea    0xece(%rip),%rdi
call   1030 <puts@plt>
lea    0xee0(%rip),%rdi
call   1030 <puts@plt>
jmp    119b <main+0x5b>
mov    %rsi,%rbx
mov    0x8(%rsi),%rdi
mov    0x2e68(%rip),%rax
mov    (%rax),%esi
call   1040 <openSerialPort@plt>
test   %eax,%eax
js     1189 <main+0x49>
mov    %eax,%ebp
nopl   (%rax)
mov    %ebp,%edi
call   1060 <amrDecode@plt>
jmp    1180 <main+0x40>
mov    0x8(%rbx),%rsi
lea    0xe6c(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x2e3e(%rip),%rax
mov    (%rax),%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [31 x i8] c"Usage: amrpulse [serial port]\0A\00"
@.str.1 = [32 x i8] c"Example: amrpulse /dev/ttyACM0\0A\00"
@EXIT_FAILURE = global i32 0
@B115200 = global i32 0
@.str.2 = [29 x i8] c"Open serial port error (%s)\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = load i32, i32* %4
%8 = icmp slt i32 %7, 2
br i1 %8, label %9, label %13
9: ; preds = %2
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0))
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0))
%12 = load i32, i32* @EXIT_FAILURE
store i32 %12, i32* %3
br label %31
13: ; preds = %2
%14 = load i8**, i8*** %5
%15 = getelementptr inbounds i8*, i8** %14, i64 1
%16 = load i8*, i8** %15
%17 = load i32, i32* @B115200
%18 = call i32 @openSerialPort(i8* %16, i32 %17)
store i32 %18, i32* %6
%19 = load i32, i32* %6
%20 = icmp slt i32 %19, 0
br i1 %20, label %21, label %27
21: ; preds = %13
%22 = load i8**, i8*** %5
%23 = getelementptr inbounds i8*, i8** %22, i64 1
%24 = load i8*, i8** %23
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0), i8* %24)
%26 = load i32, i32* @EXIT_FAILURE
store i32 %26, i32* %3
br label %31
27: ; preds = %13
br label %28
28: ; preds = %28, %27
%29 = load i32, i32* %6
%30 = call i32 @amrDecode(i32 %29)
br label %28
31: ; preds = %21, %9
%32 = load i32, i32* %3
ret i32 %32
}

LLVM IR (-O2):
@EXIT_FAILURE = global i32 0
@B115200 = global i32 0
@.str.2 = [29 x i8] c"Open serial port error (%s)\0A\00"
@EXIT_SUCCESS = global i32 0
@str = [30 x i8] c"Usage: amrpulse [serial port]\00"
@str.3 = [31 x i8] c"Example: amrpulse /dev/ttyACM0\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp slt i32 %0, 2
br i1 %3, label %4, label %7
4: ; preds = %2
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @str, i64 0, i64 0))
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @str.3, i64 0, i64 0))
br label %18
7: ; preds = %2
%8 = getelementptr inbounds i8*, i8** %1, i64 1
%9 = load i8*, i8** %8
%10 = load i32, i32* @B115200
%11 = tail call i32 @openSerialPort(i8* %9, i32 %10)
%12 = icmp slt i32 %11, 0
br i1 %12, label %13, label %16
13: ; preds = %7
%14 = load i8*, i8** %8
%15 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0), i8* %14)
br label %18
16: ; preds = %7, %16
%17 = tail call i32 @amrDecode(i32 %11)
br label %16
18: ; preds = %13, %4
%19 = load i32, i32* @EXIT_FAILURE
ret i32 %19
}