#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 *);
scalar_t__ send_modem_command(int, char *);
int /*<<< orphan*/ sleep(int);
int init_modem(int fd) {
  printf("sending ATZ command...\n");
  if (send_modem_command(fd, "ATZ\r") != 0) {
    return (-1);
  }
  sleep(1);
  if (send_modem_command(fd, "AT&D2\r") != 0) {
    return (-1);
  }
  printf("sending caller ID command...\n");
  if (send_modem_command(fd, "AT+VCID=1\r") != 0) {
    return (-1);
  }
  send_modem_command(fd, "AT+FCLASS=0\r");
  return (0);
}


x86 assembly (clang, -O0):
<init_modem>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
lea    0xebe(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%edi
lea    0xec7(%rip),%rsi
call   1040 <send_modem_command@plt>
cmp    $0x0,%rax
je     116c <init_modem+0x3c>
movl   $0xffffffff,-0x4(%rbp)
jmp    11e2 <init_modem+0xb2>
mov    $0x1,%edi
call   1050 <sleep@plt>
mov    -0x8(%rbp),%edi
lea    0xe9d(%rip),%rsi
call   1040 <send_modem_command@plt>
cmp    $0x0,%rax
je     119b <init_modem+0x6b>
movl   $0xffffffff,-0x4(%rbp)
jmp    11e2 <init_modem+0xb2>
lea    0xe82(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%edi
lea    0xe91(%rip),%rsi
call   1040 <send_modem_command@plt>
cmp    $0x0,%rax
je     11cc <init_modem+0x9c>
movl   $0xffffffff,-0x4(%rbp)
jmp    11e2 <init_modem+0xb2>
mov    -0x8(%rbp),%edi
lea    0xe77(%rip),%rsi
call   1040 <send_modem_command@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<init_modem>:
push   %rbp
push   %rbx
push   %rax
mov    %edi,%ebx
lea    0xee8(%rip),%rdi
call   1030 <puts@plt>
lea    0xeb8(%rip),%rsi
mov    %ebx,%edi
call   1040 <send_modem_command@plt>
mov    $0xffffffff,%ebp
test   %rax,%rax
jne    11a5 <init_modem+0x75>
mov    $0x1,%edi
call   1050 <sleep@plt>
lea    0xe9b(%rip),%rsi
mov    %ebx,%edi
call   1040 <send_modem_command@plt>
test   %rax,%rax
jne    11a5 <init_modem+0x75>
lea    0xebe(%rip),%rdi
call   1030 <puts@plt>
lea    0xe83(%rip),%rsi
mov    %ebx,%edi
call   1040 <send_modem_command@plt>
test   %rax,%rax
jne    11a5 <init_modem+0x75>
lea    0xe7b(%rip),%rsi
mov    %ebx,%edi
call   1040 <send_modem_command@plt>
xor    %ebp,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [24 x i8] c"sending ATZ command...\0A\00"
@.str.1 = [5 x i8] c"ATZ\0D\00"
@.str.2 = [7 x i8] c"AT&D2\0D\00"
@.str.3 = [30 x i8] c"sending caller ID command...\0A\00"
@.str.4 = [11 x i8] c"AT+VCID=1\0D\00"
@.str.5 = [13 x i8] c"AT+FCLASS=0\0D\00"
define i32 @init_modem(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %3
%4 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
%5 = load i32, i32* %3
%6 = call i64 @send_modem_command(i32 %5, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%7 = icmp ne i64 %6, 0
br i1 %7, label %8, label %9
8: ; preds = %1
store i32 -1, i32* %2
br label %24
9: ; preds = %1
%10 = call i32 @sleep(i32 1)
%11 = load i32, i32* %3
%12 = call i64 @send_modem_command(i32 %11, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
%13 = icmp ne i64 %12, 0
br i1 %13, label %14, label %15
14: ; preds = %9
store i32 -1, i32* %2
br label %24
15: ; preds = %9
%16 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.3, i64 0, i64 0))
%17 = load i32, i32* %3
%18 = call i64 @send_modem_command(i32 %17, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0))
%19 = icmp ne i64 %18, 0
br i1 %19, label %20, label %21
20: ; preds = %15
store i32 -1, i32* %2
br label %24
21: ; preds = %15
%22 = load i32, i32* %3
%23 = call i64 @send_modem_command(i32 %22, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0))
store i32 0, i32* %2
br label %24
24: ; preds = %21, %20, %14, %8
%25 = load i32, i32* %2
ret i32 %25
}

LLVM IR (-O2):
@.str.1 = [5 x i8] c"ATZ\0D\00"
@.str.2 = [7 x i8] c"AT&D2\0D\00"
@.str.4 = [11 x i8] c"AT+VCID=1\0D\00"
@.str.5 = [13 x i8] c"AT+FCLASS=0\0D\00"
@str = [23 x i8] c"sending ATZ command...\00"
@str.6 = [29 x i8] c"sending caller ID command...\00"
define i32 @init_modem(i32 %0) {
%2 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str, i64 0, i64 0))
%3 = tail call i64 @send_modem_command(i32 %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%4 = icmp eq i64 %3, 0
br i1 %4, label %5, label %15
5: ; preds = %1
%6 = tail call i32 @sleep(i32 1)
%7 = tail call i64 @send_modem_command(i32 %0, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
%8 = icmp eq i64 %7, 0
br i1 %8, label %9, label %15
9: ; preds = %5
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @str.6, i64 0, i64 0))
%11 = tail call i64 @send_modem_command(i32 %0, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0))
%12 = icmp eq i64 %11, 0
br i1 %12, label %13, label %15
13: ; preds = %9
%14 = tail call i64 @send_modem_command(i32 %0, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0))
br label %15
15: ; preds = %9, %5, %1, %13
%16 = phi i32 [ 0, %13 ], [ -1, %1 ], [ -1, %5 ], [ -1, %9 ]
ret i32 %16
}