#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*/ FILE;

/* Variables and functions */
scalar_t__ EOF;
scalar_t__ fputc(unsigned int, int /*<<< orphan*/ *);
int write_int(FILE *out, unsigned int n) {
  if (fputc((n & 255), out) == EOF)
    return -1;
  if (fputc(((n >> 8) & 255), out) == EOF)
    return -1;
  if (fputc(((n >> 16) & 255), out) == EOF)
    return -1;
  if (fputc(((n >> 24) & 255), out) == EOF)
    return -1;
  return 0;
}


x86 assembly (clang, -O0):
<write_int>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    -0x14(%rbp),%edi
and    $0xff,%edi
mov    -0x10(%rbp),%rsi
call   1030 <fputc@plt>
mov    0x2eb0(%rip),%rcx
cmp    (%rcx),%rax
jne    114d <write_int+0x3d>
movl   $0xffffffff,-0x4(%rbp)
jmp    11e7 <write_int+0xd7>
mov    -0x14(%rbp),%edi
shr    $0x8,%edi
and    $0xff,%edi
mov    -0x10(%rbp),%rsi
call   1030 <fputc@plt>
mov    0x2e7f(%rip),%rcx
cmp    (%rcx),%rax
jne    117e <write_int+0x6e>
movl   $0xffffffff,-0x4(%rbp)
jmp    11e7 <write_int+0xd7>
mov    -0x14(%rbp),%edi
shr    $0x10,%edi
and    $0xff,%edi
mov    -0x10(%rbp),%rsi
call   1030 <fputc@plt>
mov    0x2e4e(%rip),%rcx
cmp    (%rcx),%rax
jne    11af <write_int+0x9f>
movl   $0xffffffff,-0x4(%rbp)
jmp    11e7 <write_int+0xd7>
mov    -0x14(%rbp),%edi
shr    $0x18,%edi
and    $0xff,%edi
mov    -0x10(%rbp),%rsi
call   1030 <fputc@plt>
mov    0x2e1d(%rip),%rcx
cmp    (%rcx),%rax
jne    11e0 <write_int+0xd0>
movl   $0xffffffff,-0x4(%rbp)
jmp    11e7 <write_int+0xd7>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<write_int>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %esi,%ebx
mov    %rdi,%rbp
movzbl %bl,%edi
mov    %rbp,%rsi
call   1030 <fputc@plt>
mov    0x2eba(%rip),%r15
mov    $0xffffffff,%r14d
cmp    (%r15),%rax
je     1178 <write_int+0x68>
movzbl %bh,%edi
mov    %rbp,%rsi
call   1030 <fputc@plt>
cmp    (%r15),%rax
je     1178 <write_int+0x68>
mov    %ebx,%eax
shr    $0x10,%eax
movzbl %al,%edi
mov    %rbp,%rsi
call   1030 <fputc@plt>
cmp    (%r15),%rax
je     1178 <write_int+0x68>
shr    $0x18,%ebx
mov    %ebx,%edi
mov    %rbp,%rsi
call   1030 <fputc@plt>
xor    %r14d,%r14d
cmp    (%r15),%rax
sete   %r14b
neg    %r14d
mov    %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@EOF = global i64 0
define i32 @write_int(i32* %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32*
%5 = alloca i32
store i32* %0, i32** %4
store i32 %1, i32* %5
%6 = load i32, i32* %5
%7 = and i32 %6, 255
%8 = load i32*, i32** %4
%9 = call i64 @fputc(i32 %7, i32* %8)
%10 = load i64, i64* @EOF
%11 = icmp eq i64 %9, %10
br i1 %11, label %12, label %13
12: ; preds = %2
store i32 -1, i32* %3
br label %41
13: ; preds = %2
%14 = load i32, i32* %5
%15 = lshr i32 %14, 8
%16 = and i32 %15, 255
%17 = load i32*, i32** %4
%18 = call i64 @fputc(i32 %16, i32* %17)
%19 = load i64, i64* @EOF
%20 = icmp eq i64 %18, %19
br i1 %20, label %21, label %22
21: ; preds = %13
store i32 -1, i32* %3
br label %41
22: ; preds = %13
%23 = load i32, i32* %5
%24 = lshr i32 %23, 16
%25 = and i32 %24, 255
%26 = load i32*, i32** %4
%27 = call i64 @fputc(i32 %25, i32* %26)
%28 = load i64, i64* @EOF
%29 = icmp eq i64 %27, %28
br i1 %29, label %30, label %31
30: ; preds = %22
store i32 -1, i32* %3
br label %41
31: ; preds = %22
%32 = load i32, i32* %5
%33 = lshr i32 %32, 24
%34 = and i32 %33, 255
%35 = load i32*, i32** %4
%36 = call i64 @fputc(i32 %34, i32* %35)
%37 = load i64, i64* @EOF
%38 = icmp eq i64 %36, %37
br i1 %38, label %39, label %40
39: ; preds = %31
store i32 -1, i32* %3
br label %41
40: ; preds = %31
store i32 0, i32* %3
br label %41
41: ; preds = %40, %39, %30, %21, %12
%42 = load i32, i32* %3
ret i32 %42
}

LLVM IR (-O2):
@EOF = global i64 0
define i32 @write_int(i32* nocapture %0, i32 %1) {
%3 = and i32 %1, 255
%4 = tail call i64 @fputc(i32 %3, i32* %0)
%5 = load i64, i64* @EOF
%6 = icmp eq i64 %4, %5
br i1 %6, label %25, label %7
7: ; preds = %2
%8 = lshr i32 %1, 8
%9 = and i32 %8, 255
%10 = tail call i64 @fputc(i32 %9, i32* %0)
%11 = load i64, i64* @EOF
%12 = icmp eq i64 %10, %11
br i1 %12, label %25, label %13
13: ; preds = %7
%14 = lshr i32 %1, 16
%15 = and i32 %14, 255
%16 = tail call i64 @fputc(i32 %15, i32* %0)
%17 = load i64, i64* @EOF
%18 = icmp eq i64 %16, %17
br i1 %18, label %25, label %19
19: ; preds = %13
%20 = lshr i32 %1, 24
%21 = tail call i64 @fputc(i32 %20, i32* %0)
%22 = load i64, i64* @EOF
%23 = icmp eq i64 %21, %22
%24 = sext i1 %23 to i32
br label %25
25: ; preds = %19, %13, %7, %2
%26 = phi i32 [ -1, %2 ], [ -1, %7 ], [ -1, %13 ], [ %24, %19 ]
ret i32 %26
}