#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 int /*<<< orphan*/ uint32_t;
typedef scalar_t__ off_t;

/* Variables and functions */
scalar_t__ write32(int, scalar_t__, int /*<<< orphan*/);
scalar_t__ write8(int, scalar_t__, int);
int writecons(int fd, off_t addr, uint32_t car, uint32_t cdr) {
  if (write8(fd, addr, 0x00))
    return (1);
  if (write32(fd, addr + 1, car))
    return (1);
  if (write32(fd, addr + 5, cdr))
    return (1);
  return (0);
}


x86 assembly (clang, -O0):
<writecons>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
xor    %edx,%edx
call   1040 <write8@plt>
cmp    $0x0,%rax
je     1159 <writecons+0x39>
movl   $0x1,-0x4(%rbp)
jmp    11b2 <writecons+0x92>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
add    $0x1,%rsi
mov    -0x14(%rbp),%edx
call   1030 <write32@plt>
cmp    $0x0,%rax
je     1182 <writecons+0x62>
movl   $0x1,-0x4(%rbp)
jmp    11b2 <writecons+0x92>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
add    $0x5,%rsi
mov    -0x18(%rbp),%edx
call   1030 <write32@plt>
cmp    $0x0,%rax
je     11ab <writecons+0x8b>
movl   $0x1,-0x4(%rbp)
jmp    11b2 <writecons+0x92>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<writecons>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %ecx,%r14d
mov    %edx,%r12d
mov    %rsi,%rbx
mov    %edi,%r15d
xor    %edx,%edx
call   1040 <write8@plt>
mov    $0x1,%ebp
test   %rax,%rax
jne    1174 <writecons+0x54>
lea    0x1(%rbx),%rsi
mov    %r15d,%edi
mov    %r12d,%edx
call   1030 <write32@plt>
test   %rax,%rax
jne    1174 <writecons+0x54>
add    $0x5,%rbx
mov    %r15d,%edi
mov    %rbx,%rsi
mov    %r14d,%edx
call   1030 <write32@plt>
xor    %ebp,%ebp
test   %rax,%rax
setne  %bpl
mov    %ebp,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @writecons(i32 %0, i64 %1, i32 %2, i32 %3) {
%5 = alloca i32
%6 = alloca i32
%7 = alloca i64
%8 = alloca i32
%9 = alloca i32
store i32 %0, i32* %6
store i64 %1, i64* %7
store i32 %2, i32* %8
store i32 %3, i32* %9
%10 = load i32, i32* %6
%11 = load i64, i64* %7
%12 = call i64 @write8(i32 %10, i64 %11, i32 0)
%13 = icmp ne i64 %12, 0
br i1 %13, label %14, label %15
14: ; preds = %4
store i32 1, i32* %5
br label %32
15: ; preds = %4
%16 = load i32, i32* %6
%17 = load i64, i64* %7
%18 = add nsw i64 %17, 1
%19 = load i32, i32* %8
%20 = call i64 @write32(i32 %16, i64 %18, i32 %19)
%21 = icmp ne i64 %20, 0
br i1 %21, label %22, label %23
22: ; preds = %15
store i32 1, i32* %5
br label %32
23: ; preds = %15
%24 = load i32, i32* %6
%25 = load i64, i64* %7
%26 = add nsw i64 %25, 5
%27 = load i32, i32* %9
%28 = call i64 @write32(i32 %24, i64 %26, i32 %27)
%29 = icmp ne i64 %28, 0
br i1 %29, label %30, label %31
30: ; preds = %23
store i32 1, i32* %5
br label %32
31: ; preds = %23
store i32 0, i32* %5
br label %32
32: ; preds = %31, %30, %22, %14
%33 = load i32, i32* %5
ret i32 %33
}

LLVM IR (-O2):
define i32 @writecons(i32 %0, i64 %1, i32 %2, i32 %3) {
%5 = tail call i64 @write8(i32 %0, i64 %1, i32 0)
%6 = icmp eq i64 %5, 0
br i1 %6, label %7, label %16
7: ; preds = %4
%8 = add nsw i64 %1, 1
%9 = tail call i64 @write32(i32 %0, i64 %8, i32 %2)
%10 = icmp eq i64 %9, 0
br i1 %10, label %11, label %16
11: ; preds = %7
%12 = add nsw i64 %1, 5
%13 = tail call i64 @write32(i32 %0, i64 %12, i32 %3)
%14 = icmp ne i64 %13, 0
%15 = zext i1 %14 to i32
br label %16
16: ; preds = %11, %7, %4
%17 = phi i32 [ 1, %4 ], [ 1, %7 ], [ %15, %11 ]
ret i32 %17
}