#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 */
int /*<<< orphan*/ fputc(unsigned char, int /*<<< orphan*/ *);
int save_word(FILE *out, int b, int e) {
  unsigned char v;
  if (!e) {
    v = b & 0xff;
    fputc(v, out);
    v = b >> 8;
    fputc(v, out);
  } else {
    v = b >> 8;
    fputc(v, out);
    v = b & 0xff;
    fputc(v, out);
  }
  return 0;
}


x86 assembly (clang, -O0):
<save_word>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
cmpl   $0x0,-0x10(%rbp)
jne    1163 <save_word+0x53>
mov    -0xc(%rbp),%eax
and    $0xff,%eax
mov    %al,-0x11(%rbp)
mov    -0x11(%rbp),%al
mov    -0x8(%rbp),%rsi
movzbl %al,%edi
call   1030 <fputc@plt>
mov    -0xc(%rbp),%eax
sar    $0x8,%eax
mov    %al,-0x11(%rbp)
mov    -0x11(%rbp),%al
mov    -0x8(%rbp),%rsi
movzbl %al,%edi
call   1030 <fputc@plt>
jmp    1195 <save_word+0x85>
mov    -0xc(%rbp),%eax
sar    $0x8,%eax
mov    %al,-0x11(%rbp)
mov    -0x11(%rbp),%al
mov    -0x8(%rbp),%rsi
movzbl %al,%edi
call   1030 <fputc@plt>
mov    -0xc(%rbp),%eax
and    $0xff,%eax
mov    %al,-0x11(%rbp)
mov    -0x11(%rbp),%al
mov    -0x8(%rbp),%rsi
movzbl %al,%edi
call   1030 <fputc@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<save_word>:
push   %r14
push   %rbx
push   %rax
mov    %esi,%ebx
mov    %rdi,%r14
test   %edx,%edx
je     112a <save_word+0x1a>
movzbl %bh,%edi
mov    %r14,%rsi
call   1030 <fputc@plt>
jmp    1138 <save_word+0x28>
movzbl %bl,%edi
mov    %r14,%rsi
call   1030 <fputc@plt>
shr    $0x8,%ebx
movzbl %bl,%edi
mov    %r14,%rsi
call   1030 <fputc@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i32 @save_word(i32* %0, i32 %1, i32 %2) {
%4 = alloca i32*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i8
store i32* %0, i32** %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%8 = load i32, i32* %6
%9 = icmp ne i32 %8, 0
br i1 %9, label %23, label %10
10: ; preds = %3
%11 = load i32, i32* %5
%12 = and i32 %11, 255
%13 = trunc i32 %12 to i8
store i8 %13, i8* %7
%14 = load i8, i8* %7
%15 = load i32*, i32** %4
%16 = call i32 @fputc(i8 zeroext %14, i32* %15)
%17 = load i32, i32* %5
%18 = ashr i32 %17, 8
%19 = trunc i32 %18 to i8
store i8 %19, i8* %7
%20 = load i8, i8* %7
%21 = load i32*, i32** %4
%22 = call i32 @fputc(i8 zeroext %20, i32* %21)
br label %36
23: ; preds = %3
%24 = load i32, i32* %5
%25 = ashr i32 %24, 8
%26 = trunc i32 %25 to i8
store i8 %26, i8* %7
%27 = load i8, i8* %7
%28 = load i32*, i32** %4
%29 = call i32 @fputc(i8 zeroext %27, i32* %28)
%30 = load i32, i32* %5
%31 = and i32 %30, 255
%32 = trunc i32 %31 to i8
store i8 %32, i8* %7
%33 = load i8, i8* %7
%34 = load i32*, i32** %4
%35 = call i32 @fputc(i8 zeroext %33, i32* %34)
br label %36
36: ; preds = %23, %10
ret i32 0
}

LLVM IR (-O2):
define i32 @save_word(i32* nocapture %0, i32 %1, i32 %2) {
%4 = icmp eq i32 %2, 0
br i1 %4, label %5, label %9
5: ; preds = %3
%6 = trunc i32 %1 to i8
%7 = tail call i32 @fputc(i8 zeroext %6, i32* %0)
%8 = lshr i32 %1, 8
br label %13
9: ; preds = %3
%10 = lshr i32 %1, 8
%11 = trunc i32 %10 to i8
%12 = tail call i32 @fputc(i8 zeroext %11, i32* %0)
br label %13
13: ; preds = %9, %5
%14 = phi i32 [ %1, %9 ], [ %8, %5 ]
%15 = trunc i32 %14 to i8
%16 = tail call i32 @fputc(i8 zeroext %15, i32* %0)
ret i32 0
}