#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__ fputc(int, int /*<<< orphan*/ *);
int fput32(int val, FILE *f) {
  if (fputc(val >> 24, f) < 0 || fputc(val >> 16, f) < 0 ||
      fputc(val >> 8, f) < 0 || fputc(val, f) < 0) {
    return -1;
  } else {
    return 0;
  }
}


x86 assembly (clang, -O0):
<fput32>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%edi
sar    $0x18,%edi
mov    -0x10(%rbp),%rsi
call   1030 <fputc@plt>
cmp    $0x0,%rax
jl     1180 <fput32+0x70>
mov    -0x8(%rbp),%edi
sar    $0x10,%edi
mov    -0x10(%rbp),%rsi
call   1030 <fputc@plt>
cmp    $0x0,%rax
jl     1180 <fput32+0x70>
mov    -0x8(%rbp),%edi
sar    $0x8,%edi
mov    -0x10(%rbp),%rsi
call   1030 <fputc@plt>
cmp    $0x0,%rax
jl     1180 <fput32+0x70>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1030 <fputc@plt>
cmp    $0x0,%rax
jge    118c <fput32+0x7c>
movl   $0xffffffff,-0x4(%rbp)
jmp    1193 <fput32+0x83>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fput32>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%rbx
mov    %edi,%ebp
sar    $0x18,%edi
call   1030 <fputc@plt>
mov    $0xffffffff,%r14d
test   %rax,%rax
js     1161 <fput32+0x51>
mov    %ebp,%edi
sar    $0x10,%edi
mov    %rbx,%rsi
call   1030 <fputc@plt>
test   %rax,%rax
js     1161 <fput32+0x51>
mov    %ebp,%edi
sar    $0x8,%edi
mov    %rbx,%rsi
call   1030 <fputc@plt>
test   %rax,%rax
js     1161 <fput32+0x51>
mov    %ebp,%edi
mov    %rbx,%rsi
call   1030 <fputc@plt>
mov    %rax,%r14
sar    $0x3f,%r14
mov    %r14d,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define i32 @fput32(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* %4
%7 = ashr i32 %6, 24
%8 = load i32*, i32** %5
%9 = call i64 @fputc(i32 %7, i32* %8)
%10 = icmp slt i64 %9, 0
br i1 %10, label %28, label %11
11: ; preds = %2
%12 = load i32, i32* %4
%13 = ashr i32 %12, 16
%14 = load i32*, i32** %5
%15 = call i64 @fputc(i32 %13, i32* %14)
%16 = icmp slt i64 %15, 0
br i1 %16, label %28, label %17
17: ; preds = %11
%18 = load i32, i32* %4
%19 = ashr i32 %18, 8
%20 = load i32*, i32** %5
%21 = call i64 @fputc(i32 %19, i32* %20)
%22 = icmp slt i64 %21, 0
br i1 %22, label %28, label %23
23: ; preds = %17
%24 = load i32, i32* %4
%25 = load i32*, i32** %5
%26 = call i64 @fputc(i32 %24, i32* %25)
%27 = icmp slt i64 %26, 0
br i1 %27, label %28, label %29
28: ; preds = %23, %17, %11, %2
store i32 -1, i32* %3
br label %30
29: ; preds = %23
store i32 0, i32* %3
br label %30
30: ; preds = %29, %28
%31 = load i32, i32* %3
ret i32 %31
}

LLVM IR (-O2):
define i32 @fput32(i32 %0, i32* nocapture %1) {
%3 = ashr i32 %0, 24
%4 = tail call i64 @fputc(i32 %3, i32* %1)
%5 = icmp slt i64 %4, 0
br i1 %5, label %18, label %6
6: ; preds = %2
%7 = ashr i32 %0, 16
%8 = tail call i64 @fputc(i32 %7, i32* %1)
%9 = icmp slt i64 %8, 0
br i1 %9, label %18, label %10
10: ; preds = %6
%11 = ashr i32 %0, 8
%12 = tail call i64 @fputc(i32 %11, i32* %1)
%13 = icmp slt i64 %12, 0
br i1 %13, label %18, label %14
14: ; preds = %10
%15 = tail call i64 @fputc(i32 %0, i32* %1)
%16 = ashr i64 %15, 63
%17 = trunc i64 %16 to i32
br label %18
18: ; preds = %14, %2, %6, %10
%19 = phi i32 [ -1, %10 ], [ -1, %6 ], [ -1, %2 ], [ %17, %14 ]
ret i32 %19
}