#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 *);
int /*<<< orphan*/ sleep(int);
scalar_t__ strlen(char *);
scalar_t__ write(int, char *, scalar_t__);
int send_timed_modem_command(int fd, char *command, int numSecs) {
  if (write(fd, command, strlen(command)) != strlen(command)) {
    printf("send_timed_modem_command: write() failed\n");
  }
  sleep(numSecs);
  return (0);
}


x86 assembly (clang, -O0):
<send_timed_modem_command>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x2c(%rbp),%edi
mov    -0x28(%rbp),%rsi
mov    %rax,%rdx
call   1030 <write@plt>
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    %rax,%rcx
mov    -0x20(%rbp),%rax
cmp    %rcx,%rax
je     11a1 <send_timed_modem_command+0x61>
lea    0xe64(%rip),%rdi
call   1050 <printf@plt>
mov    -0x14(%rbp),%edi
call   1060 <sleep@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<send_timed_modem_command>:
push   %rbp
push   %r14
push   %rbx
mov    %edx,%r14d
mov    %rsi,%rbx
mov    %edi,%ebp
mov    %rsi,%rdi
call   1050 <strlen@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %rax,%rdx
call   1040 <write@plt>
mov    %rax,%rbp
mov    %rbx,%rdi
call   1050 <strlen@plt>
cmp    %rax,%rbp
je     117d <send_timed_modem_command+0x3d>
lea    0xe88(%rip),%rdi
call   1030 <puts@plt>
mov    %r14d,%edi
call   1060 <sleep@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [42 x i8] c"send_timed_modem_command: write() failed\0A\00"
define i32 @send_timed_modem_command(i32 %0, i8* %1, i32 %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i32
store i32 %0, i32* %4
store i8* %1, i8** %5
store i32 %2, i32* %6
%7 = load i32, i32* %4
%8 = load i8*, i8** %5
%9 = load i8*, i8** %5
%10 = call i64 @strlen(i8* %9)
%11 = call i64 @write(i32 %7, i8* %8, i64 %10)
%12 = load i8*, i8** %5
%13 = call i64 @strlen(i8* %12)
%14 = icmp ne i64 %11, %13
br i1 %14, label %15, label %17
15: ; preds = %3
%16 = call i32 @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str, i64 0, i64 0))
br label %17
17: ; preds = %15, %3
%18 = load i32, i32* %6
%19 = call i32 @sleep(i32 %18)
ret i32 0
}

LLVM IR (-O2):
@str = [41 x i8] c"send_timed_modem_command: write() failed\00"
define i32 @send_timed_modem_command(i32 %0, i8* nocapture %1, i32 %2) {
%4 = tail call i64 @strlen(i8* dereferenceable(1) %1)
%5 = tail call i64 @write(i32 %0, i8* %1, i64 %4)
%6 = tail call i64 @strlen(i8* dereferenceable(1) %1)
%7 = icmp eq i64 %5, %6
br i1 %7, label %10, label %8
8: ; preds = %3
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @str, i64 0, i64 0))
br label %10
10: ; preds = %8, %3
%11 = tail call i32 @sleep(i32 %2)
ret i32 0
}