#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 wchar_t;
typedef int /*<<< orphan*/ buf;

/* Variables and functions */
int WEOF;
int /*<<< orphan*/ feof(int /*<<< orphan*/);
int getwc(int /*<<< orphan*/);
int /*<<< orphan*/ stdin;
scalar_t__ wcscmp(int *, char *);
int /*<<< orphan*/ wmemset(int *, int, int);
int main(void) {
  wchar_t buf[100];
  size_t n = 0;
  wmemset(buf, L'\0', sizeof(buf) / sizeof(buf[0]));
  while (!feof(stdin) && n < sizeof(buf) - 1) {
    buf[n] = getwc(stdin);
    if (buf[n] == WEOF)
      break;
    ++n;
  }
  buf[n] = L'\0';
  return wcscmp(buf, L"This is a test of getwc\n") != 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1b0,%rsp
movl   $0x0,-0x4(%rbp)
movq   $0x0,-0x1a8(%rbp)
lea    -0x1a0(%rbp),%rdi
xor    %esi,%esi
mov    $0x64,%edx
call   1040 <wmemset@plt>
mov    0x2e71(%rip),%rax
mov    (%rax),%edi
call   1050 <feof@plt>
mov    %eax,%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x1a9(%rbp)
jne    11a5 <main+0x65>
cmpq   $0x18f,-0x1a8(%rbp)
setb   %al
mov    %al,-0x1a9(%rbp)
mov    -0x1a9(%rbp),%al
test   $0x1,%al
jne    11b8 <main+0x78>
jmp    120f <main+0xcf>
mov    0x2e29(%rip),%rax
mov    (%rax),%edi
call   1060 <getwc@plt>
mov    %eax,%ecx
mov    -0x1a8(%rbp),%rax
mov    %ecx,-0x1a0(%rbp,%rax,4)
mov    -0x1a8(%rbp),%rax
mov    -0x1a0(%rbp,%rax,4),%eax
mov    0x2ded(%rip),%rcx
cmp    (%rcx),%eax
jne    11f8 <main+0xb8>
jmp    120f <main+0xcf>
mov    -0x1a8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x1a8(%rbp)
jmp    1170 <main+0x30>
mov    -0x1a8(%rbp),%rax
movl   $0x0,-0x1a0(%rbp,%rax,4)
lea    -0x1a0(%rbp),%rdi
lea    0xdd1(%rip),%rsi
call   1030 <wcscmp@plt>
cmp    $0x0,%rax
setne  %al
and    $0x1,%al
movzbl %al,%eax
add    $0x1b0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x198,%rsp
mov    %rsp,%rdi
xor    %r15d,%r15d
xor    %esi,%esi
mov    $0x64,%edx
call   1040 <wmemset@plt>
mov    0x2e81(%rip),%r14
mov    (%r14),%edi
call   1050 <feof@plt>
test   %eax,%eax
jne    11b2 <main+0x72>
xor    %ebx,%ebx
mov    0x2e5c(%rip),%r12
nopl   0x0(%rax)
mov    (%r14),%edi
call   1060 <getwc@plt>
mov    %eax,(%rsp,%rbx,4)
cmp    (%r12),%eax
je     11af <main+0x6f>
lea    0x1(%rbx),%r15
mov    (%r14),%edi
call   1050 <feof@plt>
test   %eax,%eax
jne    11b2 <main+0x72>
cmp    $0x18e,%rbx
mov    %r15,%rbx
jb     1180 <main+0x40>
jmp    11b2 <main+0x72>
mov    %rbx,%r15
movl   $0x0,(%rsp,%r15,4)
lea    0xe3f(%rip),%rsi
mov    %rsp,%rdi
call   1030 <wcscmp@plt>
xor    %ecx,%ecx
test   %rax,%rax
setne  %cl
mov    %ecx,%eax
add    $0x198,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@stdin = global i32 0
@WEOF = global i32 0
@.str = [25 x i32] [i32 84, i32 104, i32 105, i32 115, i32 32, i32 105, i32 115, i32 32, i32 97, i32 32, i32 116, i32 101, i32 115, i32 116, i32 32, i32 111, i32 102, i32 32, i32 103, i32 101, i32 116, i32 119, i32 99, i32 10, i32 0]
define i32 @main() {
%1 = alloca i32
%2 = alloca [100 x i32]
%3 = alloca i64
store i32 0, i32* %1
store i64 0, i64* %3
%4 = getelementptr inbounds [100 x i32], [100 x i32]* %2, i64 0, i64 0
%5 = call i32 @wmemset(i32* %4, i32 0, i32 100)
br label %6
6: ; preds = %26, %0
%7 = load i32, i32* @stdin
%8 = call i32 @feof(i32 %7)
%9 = icmp ne i32 %8, 0
br i1 %9, label %13, label %10
10: ; preds = %6
%11 = load i64, i64* %3
%12 = icmp ult i64 %11, 399
br label %13
13: ; preds = %10, %6
%14 = phi i1 [ false, %6 ], [ %12, %10 ]
br i1 %14, label %15, label %29
15: ; preds = %13
%16 = load i32, i32* @stdin
%17 = call i32 @getwc(i32 %16)
%18 = load i64, i64* %3
%19 = getelementptr inbounds [100 x i32], [100 x i32]* %2, i64 0, i64 %18
store i32 %17, i32* %19
%20 = load i64, i64* %3
%21 = getelementptr inbounds [100 x i32], [100 x i32]* %2, i64 0, i64 %20
%22 = load i32, i32* %21
%23 = load i32, i32* @WEOF
%24 = icmp eq i32 %22, %23
br i1 %24, label %25, label %26
25: ; preds = %15
br label %29
26: ; preds = %15
%27 = load i64, i64* %3
%28 = add i64 %27, 1
store i64 %28, i64* %3
br label %6
29: ; preds = %25, %13
%30 = load i64, i64* %3
%31 = getelementptr inbounds [100 x i32], [100 x i32]* %2, i64 0, i64 %30
store i32 0, i32* %31
%32 = getelementptr inbounds [100 x i32], [100 x i32]* %2, i64 0, i64 0
%33 = call i64 @wcscmp(i32* %32, i8* bitcast ([25 x i32]* @.str to i8*))
%34 = icmp ne i64 %33, 0
%35 = zext i1 %34 to i32
ret i32 %35
}

LLVM IR (-O2):
@stdin = global i32 0
@WEOF = global i32 0
@.str = [25 x i32] [i32 84, i32 104, i32 105, i32 115, i32 32, i32 105, i32 115, i32 32, i32 97, i32 32, i32 116, i32 101, i32 115, i32 116, i32 32, i32 111, i32 102, i32 32, i32 103, i32 101, i32 116, i32 119, i32 99, i32 10, i32 0]
define i32 @main() {
%1 = alloca [100 x i32]
%2 = bitcast [100 x i32]* %1 to i8*
%3 = getelementptr inbounds [100 x i32], [100 x i32]* %1, i64 0, i64 0
%4 = call i32 @wmemset(i32* %3, i32 0, i32 100)
%5 = load i32, i32* @stdin
%6 = call i32 @feof(i32 %5)
%7 = icmp eq i32 %6, 0
br i1 %7, label %8, label %22
8: ; preds = %0, %15
%9 = phi i64 [ %16, %15 ], [ 0, %0 ]
%10 = load i32, i32* @stdin
%11 = call i32 @getwc(i32 %10)
%12 = getelementptr inbounds [100 x i32], [100 x i32]* %1, i64 0, i64 %9
store i32 %11, i32* %12
%13 = load i32, i32* @WEOF
%14 = icmp eq i32 %11, %13
br i1 %14, label %22, label %15
15: ; preds = %8
%16 = add nuw nsw i64 %9, 1
%17 = load i32, i32* @stdin
%18 = call i32 @feof(i32 %17)
%19 = icmp eq i32 %18, 0
%20 = icmp ult i64 %9, 398
%21 = select i1 %19, i1 %20, i1 false
br i1 %21, label %8, label %22
22: ; preds = %15, %8, %0
%23 = phi i64 [ 0, %0 ], [ %9, %8 ], [ %16, %15 ]
%24 = getelementptr inbounds [100 x i32], [100 x i32]* %1, i64 0, i64 %23
store i32 0, i32* %24
%25 = call i64 @wcscmp(i32* %3, i8* bitcast ([25 x i32]* @.str to i8*))
%26 = icmp ne i64 %25, 0
%27 = zext i1 %26 to i32
ret i32 %27
}