#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 */
scalar_t__ _rpi_nano_exit_AT(int);
int _rpi_nano_set_reg(int, char *, int);
scalar_t__ _rpi_nano_switch_to_AT(int);
int rpi_nano_set_dest_modem_address(int fd, int address) {
  int err = -1;
  if (_rpi_nano_switch_to_AT(fd))
    return -1;
  err = _rpi_nano_set_reg(fd, "S090", address);
  if (_rpi_nano_exit_AT(fd))
    return -1;
  return err;
}


x86 assembly (clang, -O0):
<rpi_nano_set_dest_modem_address>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movl   $0xffffffff,-0x10(%rbp)
mov    -0x8(%rbp),%edi
call   1030 <_rpi_nano_switch_to_AT@plt>
cmp    $0x0,%rax
je     1163 <rpi_nano_set_dest_modem_address+0x33>
movl   $0xffffffff,-0x4(%rbp)
jmp    119c <rpi_nano_set_dest_modem_address+0x6c>
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%edx
lea    0xe90(%rip),%rsi
call   1040 <_rpi_nano_set_reg@plt>
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%edi
call   1050 <_rpi_nano_exit_AT@plt>
cmp    $0x0,%rax
je     1196 <rpi_nano_set_dest_modem_address+0x66>
movl   $0xffffffff,-0x4(%rbp)
jmp    119c <rpi_nano_set_dest_modem_address+0x6c>
mov    -0x10(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rpi_nano_set_dest_modem_address>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebp
mov    %edi,%ebx
call   1030 <_rpi_nano_switch_to_AT@plt>
mov    %rax,%rcx
mov    $0xffffffff,%eax
test   %rcx,%rcx
jne    1169 <rpi_nano_set_dest_modem_address+0x39>
lea    0xeb0(%rip),%rsi
mov    %ebx,%edi
mov    %ebp,%edx
call   1040 <_rpi_nano_set_reg@plt>
mov    %eax,%ebp
mov    %ebx,%edi
call   1050 <_rpi_nano_exit_AT@plt>
neg    %rax
sbb    %eax,%eax
or     %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [5 x i8] c"S090\00"
define i32 @rpi_nano_set_dest_modem_address(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
store i32 -1, i32* %6
%7 = load i32, i32* %4
%8 = call i64 @_rpi_nano_switch_to_AT(i32 %7)
%9 = icmp ne i64 %8, 0
br i1 %9, label %10, label %11
10: ; preds = %2
store i32 -1, i32* %3
br label %21
11: ; preds = %2
%12 = load i32, i32* %4
%13 = load i32, i32* %5
%14 = call i32 @_rpi_nano_set_reg(i32 %12, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %13)
store i32 %14, i32* %6
%15 = load i32, i32* %4
%16 = call i64 @_rpi_nano_exit_AT(i32 %15)
%17 = icmp ne i64 %16, 0
br i1 %17, label %18, label %19
18: ; preds = %11
store i32 -1, i32* %3
br label %21
19: ; preds = %11
%20 = load i32, i32* %6
store i32 %20, i32* %3
br label %21
21: ; preds = %19, %18, %10
%22 = load i32, i32* %3
ret i32 %22
}

LLVM IR (-O2):
@.str = [5 x i8] c"S090\00"
define i32 @rpi_nano_set_dest_modem_address(i32 %0, i32 %1) {
%3 = tail call i64 @_rpi_nano_switch_to_AT(i32 %0)
%4 = icmp eq i64 %3, 0
br i1 %4, label %5, label %10
5: ; preds = %2
%6 = tail call i32 @_rpi_nano_set_reg(i32 %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %1)
%7 = tail call i64 @_rpi_nano_exit_AT(i32 %0)
%8 = icmp eq i64 %7, 0
%9 = select i1 %8, i32 %6, i32 -1
br label %10
10: ; preds = %5, %2
%11 = phi i32 [ -1, %2 ], [ %9, %5 ]
ret i32 %11
}