#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*/ perror(char *);
int write(int, float *, int);
void tdl_write(int fd, float pos[3], float orient[9]) {
  int posSize = 3 * (signed int)sizeof(float);
  int orientSize = 9 * (signed int)sizeof(float);
  if (write(fd, pos, posSize) < posSize) {
    perror("Writing position failed");
  }
  if (write(fd, orient, orientSize) < orientSize) {
    perror("Writing orientation failed");
  }
}


x86 assembly (clang, -O0):
<tdl_write>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movl   $0xc,-0x1c(%rbp)
movl   $0x24,-0x20(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x1c(%rbp),%edx
call   1030 <write@plt>
cmp    -0x1c(%rbp),%eax
jge    1165 <tdl_write+0x45>
lea    0xea0(%rip),%rdi
call   1040 <perror@plt>
mov    -0x4(%rbp),%edi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%edx
call   1030 <write@plt>
cmp    -0x20(%rbp),%eax
jge    1189 <tdl_write+0x69>
lea    0xe94(%rip),%rdi
call   1040 <perror@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<tdl_write>:
push   %rbp
push   %rbx
push   %rax
mov    %rdx,%rbx
mov    %edi,%ebp
mov    $0xc,%edx
call   1030 <write@plt>
cmp    $0xb,%eax
jle    1152 <tdl_write+0x32>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    $0x24,%edx
call   1030 <write@plt>
cmp    $0x23,%eax
jle    1160 <tdl_write+0x40>
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret
lea    0xea7(%rip),%rdi
call   1040 <perror@plt>
jmp    1137 <tdl_write+0x17>
lea    0xeb1(%rip),%rdi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1040 <perror@plt>

LLVM IR (-O0):
@.str = [24 x i8] c"Writing position failed\00"
@.str.1 = [27 x i8] c"Writing orientation failed\00"
define void @tdl_write(i32 %0, float* %1, float* %2) {
%4 = alloca i32
%5 = alloca float*
%6 = alloca float*
%7 = alloca i32
%8 = alloca i32
store i32 %0, i32* %4
store float* %1, float** %5
store float* %2, float** %6
store i32 12, i32* %7
store i32 36, i32* %8
%9 = load i32, i32* %4
%10 = load float*, float** %5
%11 = load i32, i32* %7
%12 = call i32 @write(i32 %9, float* %10, i32 %11)
%13 = load i32, i32* %7
%14 = icmp slt i32 %12, %13
br i1 %14, label %15, label %17
15: ; preds = %3
%16 = call i32 @perror(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
br label %17
17: ; preds = %15, %3
%18 = load i32, i32* %4
%19 = load float*, float** %6
%20 = load i32, i32* %8
%21 = call i32 @write(i32 %18, float* %19, i32 %20)
%22 = load i32, i32* %8
%23 = icmp slt i32 %21, %22
br i1 %23, label %24, label %26
24: ; preds = %17
%25 = call i32 @perror(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0))
br label %26
26: ; preds = %24, %17
ret void
}

LLVM IR (-O2):
@.str = [24 x i8] c"Writing position failed\00"
@.str.1 = [27 x i8] c"Writing orientation failed\00"
define void @tdl_write(i32 %0, float* nocapture %1, float* nocapture %2) {
%4 = tail call i32 @write(i32 %0, float* %1, i32 12)
%5 = icmp slt i32 %4, 12
br i1 %5, label %6, label %8
6: ; preds = %3
%7 = tail call i32 @perror(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
br label %8
8: ; preds = %6, %3
%9 = tail call i32 @write(i32 %0, float* %2, i32 36)
%10 = icmp slt i32 %9, 36
br i1 %10, label %11, label %13
11: ; preds = %8
%12 = tail call i32 @perror(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0))
br label %13
13: ; preds = %11, %8
ret void
}