#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*/ errno;
int /*<<< orphan*/ logcat(char *, ...);
int /*<<< orphan*/ strerror(int /*<<< orphan*/);
int uart_open_dev(char *);
int uart_set_parity(int, int, int, char);
int /*<<< orphan*/ uart_set_speed(int, int);
int Modem_Init(void) {
  int fd;
  fd = uart_open_dev("/dev/ttyUSB3");
  if (fd == -1) {
    logcat("Modem open uart: %s\n", strerror(errno));
    return -1;
  }
  uart_set_speed(fd, 115200);
  if (uart_set_parity(fd, 8, 1, 'N') == -1) {
    logcat("Set Parity Error\n");
    return -1;
  }
  return fd;
}


x86 assembly (clang, -O0):
<Modem_Init>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xea1(%rip),%rdi
call   1030 <uart_open_dev@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0xffffffff,-0x8(%rbp)
jne    119b <Modem_Init+0x4b>
mov    0x2e68(%rip),%rax
mov    (%rax),%edi
call   1070 <strerror@plt>
mov    %eax,%esi
lea    0xe85(%rip),%rdi
mov    $0x0,%al
call   1040 <logcat@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11e8 <Modem_Init+0x98>
mov    -0x8(%rbp),%edi
mov    $0x1c200,%esi
call   1050 <uart_set_speed@plt>
mov    -0x8(%rbp),%edi
mov    $0x8,%esi
mov    $0x1,%edx
mov    $0x4e,%ecx
call   1060 <uart_set_parity@plt>
cmp    $0xffffffff,%eax
jne    11e2 <Modem_Init+0x92>
lea    0xe53(%rip),%rdi
mov    $0x0,%al
call   1040 <logcat@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11e8 <Modem_Init+0x98>
mov    -0x8(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Modem_Init>:
push   %rbx
lea    0xea8(%rip),%rdi
call   1030 <uart_open_dev@plt>
cmp    $0xffffffff,%eax
je     119b <Modem_Init+0x4b>
mov    %eax,%ebx
mov    %eax,%edi
mov    $0x1c200,%esi
call   1050 <uart_set_speed@plt>
mov    %ebx,%edi
mov    $0x8,%esi
mov    $0x1,%edx
mov    $0x4e,%ecx
call   1060 <uart_set_parity@plt>
cmp    $0xffffffff,%eax
jne    11be <Modem_Init+0x6e>
lea    0xe90(%rip),%rdi
xor    %eax,%eax
call   1040 <logcat@plt>
jmp    11b9 <Modem_Init+0x69>
mov    0x2e3e(%rip),%rax
mov    (%rax),%edi
call   1070 <strerror@plt>
lea    0xe5d(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <logcat@plt>
mov    $0xffffffff,%ebx
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [13 x i8] c"/dev/ttyUSB3\00"
@.str.1 = [21 x i8] c"Modem open uart: %s\0A\00"
@errno = global i32 0
@.str.2 = [18 x i8] c"Set Parity Error\0A\00"
define i32 @Modem_Init() {
%1 = alloca i32
%2 = alloca i32
%3 = call i32 @uart_open_dev(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
store i32 %3, i32* %2
%4 = load i32, i32* %2
%5 = icmp eq i32 %4, -1
br i1 %5, label %6, label %10
6: ; preds = %0
%7 = load i32, i32* @errno
%8 = call i32 @strerror(i32 %7)
%9 = call i32 (i8*, ...) @logcat(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i32 %8)
store i32 -1, i32* %1
br label %20
10: ; preds = %0
%11 = load i32, i32* %2
%12 = call i32 @uart_set_speed(i32 %11, i32 115200)
%13 = load i32, i32* %2
%14 = call i32 @uart_set_parity(i32 %13, i32 8, i32 1, i8 signext 78)
%15 = icmp eq i32 %14, -1
br i1 %15, label %16, label %18
16: ; preds = %10
%17 = call i32 (i8*, ...) @logcat(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0))
store i32 -1, i32* %1
br label %20
18: ; preds = %10
%19 = load i32, i32* %2
store i32 %19, i32* %1
br label %20
20: ; preds = %18, %16, %6
%21 = load i32, i32* %1
ret i32 %21
}

LLVM IR (-O2):
@.str = [13 x i8] c"/dev/ttyUSB3\00"
@.str.1 = [21 x i8] c"Modem open uart: %s\0A\00"
@errno = global i32 0
@.str.2 = [18 x i8] c"Set Parity Error\0A\00"
define i32 @Modem_Init() {
%1 = tail call i32 @uart_open_dev(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%2 = icmp eq i32 %1, -1
br i1 %2, label %3, label %7
3: ; preds = %0
%4 = load i32, i32* @errno
%5 = tail call i32 @strerror(i32 %4)
%6 = tail call i32 (i8*, ...) @logcat(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i32 %5)
br label %13
7: ; preds = %0
%8 = tail call i32 @uart_set_speed(i32 %1, i32 115200)
%9 = tail call i32 @uart_set_parity(i32 %1, i32 8, i32 1, i8 signext 78)
%10 = icmp eq i32 %9, -1
br i1 %10, label %11, label %13
11: ; preds = %7
%12 = tail call i32 (i8*, ...) @logcat(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0))
br label %13
13: ; preds = %7, %11, %3
%14 = phi i32 [ -1, %3 ], [ -1, %11 ], [ %1, %7 ]
ret i32 %14
}