#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 */
typedef scalar_t__ uint8_t;

/* Variables and functions */
int /*<<< orphan*/ RS232_CloseComport();
scalar_t__ RS232_OpenComport(char *);
int /*<<< orphan*/ RS232_disableDTR();
int /*<<< orphan*/ RS232_disableRTS();
int /*<<< orphan*/ RS232_enableDTR();
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ usleep(scalar_t__);
int serial_init(char *argument, uint8_t __timer) {
  printf("> Trying to open the [%s]...\n", argument);
  if (RS232_OpenComport(argument)) {
    return (1);
  }
  printf("> Toggling DTR...\n");
  RS232_disableRTS();
  RS232_disableDTR();
  usleep(200000L);
  RS232_enableDTR();
  usleep(200000L);
  RS232_CloseComport();
  if (__timer > 0) {
    usleep(__timer);
  }
  return 0;
}


x86 assembly (clang, -O0):
<serial_init>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rsi
lea    0xe75(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1080 <RS232_OpenComport@plt>
cmp    $0x0,%rax
je     11b1 <serial_init+0x41>
movl   $0x1,-0x4(%rbp)
jmp    120a <serial_init+0x9a>
lea    0xe66(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0x0,%al
call   1070 <RS232_disableRTS@plt>
mov    $0x0,%al
call   1040 <RS232_disableDTR@plt>
mov    $0x30d40,%edi
call   1090 <usleep@plt>
mov    $0x0,%al
call   1030 <RS232_enableDTR@plt>
mov    $0x30d40,%edi
call   1090 <usleep@plt>
mov    $0x0,%al
call   1060 <RS232_CloseComport@plt>
cmpq   $0x0,-0x18(%rbp)
jle    1203 <serial_init+0x93>
mov    -0x18(%rbp),%rdi
call   1090 <usleep@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<serial_init>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
lea    0xe6f(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %rbx,%rdi
call   1090 <RS232_OpenComport@plt>
mov    %rax,%rcx
mov    $0x1,%eax
test   %rcx,%rcx
jne    11fb <serial_init+0x7b>
lea    0xe67(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
call   1080 <RS232_disableRTS@plt>
xor    %eax,%eax
call   1050 <RS232_disableDTR@plt>
mov    $0x30d40,%edi
call   10a0 <usleep@plt>
xor    %eax,%eax
call   1030 <RS232_enableDTR@plt>
mov    $0x30d40,%edi
call   10a0 <usleep@plt>
xor    %eax,%eax
call   1070 <RS232_CloseComport@plt>
test   %r14,%r14
jle    11f9 <serial_init+0x79>
mov    %r14,%rdi
call   10a0 <usleep@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [30 x i8] c"> Trying to open the [%s]...\0A\00"
@.str.1 = [19 x i8] c"> Toggling DTR...\0A\00"
define i32 @serial_init(i8* %0, i64 %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i64
store i8* %0, i8** %4
store i64 %1, i64* %5
%6 = load i8*, i8** %4
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i8* %6)
%8 = load i8*, i8** %4
%9 = call i64 @RS232_OpenComport(i8* %8)
%10 = icmp ne i64 %9, 0
br i1 %10, label %11, label %12
11: ; preds = %2
store i32 1, i32* %3
br label %26
12: ; preds = %2
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0))
%14 = call i32 (...) @RS232_disableRTS()
%15 = call i32 (...) @RS232_disableDTR()
%16 = call i32 @usleep(i64 200000)
%17 = call i32 (...) @RS232_enableDTR()
%18 = call i32 @usleep(i64 200000)
%19 = call i32 (...) @RS232_CloseComport()
%20 = load i64, i64* %5
%21 = icmp sgt i64 %20, 0
br i1 %21, label %22, label %25
22: ; preds = %12
%23 = load i64, i64* %5
%24 = call i32 @usleep(i64 %23)
br label %25
25: ; preds = %22, %12
store i32 0, i32* %3
br label %26
26: ; preds = %25, %11
%27 = load i32, i32* %3
ret i32 %27
}

LLVM IR (-O2):
@.str = [30 x i8] c"> Trying to open the [%s]...\0A\00"
@str = [18 x i8] c"> Toggling DTR...\00"
define i32 @serial_init(i8* %0, i64 %1) {
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i8* %0)
%4 = tail call i64 @RS232_OpenComport(i8* %0)
%5 = icmp eq i64 %4, 0
br i1 %5, label %6, label %17
6: ; preds = %2
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str, i64 0, i64 0))
%8 = tail call i32 (...) @RS232_disableRTS()
%9 = tail call i32 (...) @RS232_disableDTR()
%10 = tail call i32 @usleep(i64 200000)
%11 = tail call i32 (...) @RS232_enableDTR()
%12 = tail call i32 @usleep(i64 200000)
%13 = tail call i32 (...) @RS232_CloseComport()
%14 = icmp sgt i64 %1, 0
br i1 %14, label %15, label %17
15: ; preds = %6
%16 = tail call i32 @usleep(i64 %1)
br label %17
17: ; preds = %6, %15, %2
%18 = phi i32 [ 1, %2 ], [ 0, %15 ], [ 0, %6 ]
ret i32 %18
}