#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 __builtin_ldwio(void *);
int /*<<< orphan*/ __builtin_stwio(void *, int);
int putchar(int ch) {
  int i = 100000;
  while (!(__builtin_ldwio(
               ((void *)(((unsigned char *)(0x018810e0)) + (((1)) * (4))))) &
           0xFFFF0000ul)) {
    i--;
    if (!i)
      return -1;
  }
  __builtin_stwio(((void *)(((unsigned char *)(0x018810e0)) + (((0)) * (4)))),
                  (ch));
  return 0;
}


x86 assembly (clang, -O0):
<putchar>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
movl   $0x186a0,-0xc(%rbp)
mov    $0x18810e0,%edi
add    $0x4,%rdi
call   1030 <__builtin_ldwio@plt>
cltq
movabs $0xffff0000,%rcx
and    %rcx,%rax
cmp    $0x0,%rax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    1165 <putchar+0x45>
jmp    1189 <putchar+0x69>
mov    -0xc(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jne    1184 <putchar+0x64>
movl   $0xffffffff,-0x4(%rbp)
jmp    119d <putchar+0x7d>
jmp    1132 <putchar+0x12>
mov    -0x8(%rbp),%esi
mov    $0x18810e0,%edi
call   1040 <__builtin_stwio@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<putchar>:
push   %rbp
push   %rbx
push   %rax
mov    %edi,%ebx
mov    $0xfffe7960,%ebp
nopw   0x0(%rax,%rax,1)
mov    $0x18810e4,%edi
call   1030 <__builtin_ldwio@plt>
cmp    $0xffff,%eax
ja     114c <putchar+0x2c>
inc    %ebp
jne    1130 <putchar+0x10>
mov    $0xffffffff,%eax
jmp    115a <putchar+0x3a>
mov    $0x18810e0,%edi
mov    %ebx,%esi
call   1040 <__builtin_stwio@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define i32 @putchar(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 %0, i32* %3
store i32 100000, i32* %4
br label %5
5: ; preds = %17, %1
%6 = call i32 @__builtin_ldwio(i8* getelementptr inbounds (i8, i8* inttoptr (i64 25694432 to i8*), i64 4))
%7 = sext i32 %6 to i64
%8 = and i64 %7, 4294901760
%9 = icmp ne i64 %8, 0
%10 = xor i1 %9, true
br i1 %10, label %11, label %18
11: ; preds = %5
%12 = load i32, i32* %4
%13 = add nsw i32 %12, -1
store i32 %13, i32* %4
%14 = load i32, i32* %4
%15 = icmp ne i32 %14, 0
br i1 %15, label %17, label %16
16: ; preds = %11
store i32 -1, i32* %2
br label %21
17: ; preds = %11
br label %5
18: ; preds = %5
%19 = load i32, i32* %3
%20 = call i32 @__builtin_stwio(i8* inttoptr (i64 25694432 to i8*), i32 %19)
store i32 0, i32* %2
br label %21
21: ; preds = %18, %16
%22 = load i32, i32* %2
ret i32 %22
}

LLVM IR (-O2):
define i32 @putchar(i32 %0) {
br label %2
2: ; preds = %6, %1
%3 = phi i32 [ 100000, %1 ], [ %7, %6 ]
%4 = tail call i32 @__builtin_ldwio(i8* inttoptr (i64 25694436 to i8*))
%5 = icmp ult i32 %4, 65536
br i1 %5, label %6, label %9
6: ; preds = %2
%7 = add nsw i32 %3, -1
%8 = icmp eq i32 %7, 0
br i1 %8, label %11, label %2
9: ; preds = %2
%10 = tail call i32 @__builtin_stwio(i8* inttoptr (i64 25694432 to i8*), i32 %0)
br label %11
11: ; preds = %6, %9
%12 = phi i32 [ 0, %9 ], [ -1, %6 ]
ret i32 %12
}