#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 /*<<< orphan*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdin;
int /*<<< orphan*/ stdout;
int main(int argc, char *argv[]) {
  char buf;
  char nl = '\012';
  int i;
  char input[200];
  while (1) {
    int j;
    if (NULL == fgets(input, 200, stdin))
      break;
    fprintf(stdout, "stdout - %s", input);
    fflush(stdout);
    if (NULL == fgets(input, 200, stdin))
      break;
    fprintf(stderr, "stderr - %s", input);
    fflush(stderr);
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xf0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movb   $0xa,-0x12(%rbp)
lea    -0xe0(%rbp),%rdi
mov    0x2e8d(%rip),%rax
mov    (%rax),%edx
mov    $0xc8,%esi
call   1030 <fgets@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
jne    117a <main+0x4a>
jmp    1200 <main+0xd0>
mov    0x2e4f(%rip),%rax
mov    (%rax),%edi
lea    -0xe0(%rbp),%rdx
lea    0xe6f(%rip),%rsi
call   1040 <fprintf@plt>
mov    0x2e33(%rip),%rax
mov    (%rax),%edi
call   1050 <fflush@plt>
lea    -0xe0(%rbp),%rdi
mov    0x2e36(%rip),%rax
mov    (%rax),%edx
mov    $0xc8,%esi
call   1030 <fgets@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
jne    11d1 <main+0xa1>
jmp    1200 <main+0xd0>
mov    0x2e00(%rip),%rax
mov    (%rax),%edi
lea    -0xe0(%rbp),%rdx
lea    0xe24(%rip),%rsi
call   1040 <fprintf@plt>
mov    0x2de4(%rip),%rax
mov    (%rax),%edi
call   1050 <fflush@plt>
jmp    114d <main+0x1d>
mov    -0x4(%rbp),%eax
add    $0xf0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xc8,%rsp
mov    0x2ea0(%rip),%r12
mov    (%r12),%edx
mov    %rsp,%rdi
mov    $0xc8,%esi
call   1030 <fgets@plt>
test   %rax,%rax
je     11da <main+0xaa>
mov    0x2e6b(%rip),%r13
lea    0xe94(%rip),%r14
mov    %rsp,%rbx
mov    0x2e62(%rip),%rbp
lea    0xe8f(%rip),%r15
nopl   (%rax)
mov    0x0(%r13),%edi
mov    %r14,%rsi
mov    %rbx,%rdx
call   1040 <fprintf@plt>
mov    0x0(%r13),%edi
call   1050 <fflush@plt>
mov    (%r12),%edx
mov    %rbx,%rdi
mov    $0xc8,%esi
call   1030 <fgets@plt>
test   %rax,%rax
je     11da <main+0xaa>
mov    0x0(%rbp),%edi
mov    %r15,%rsi
mov    %rbx,%rdx
call   1040 <fprintf@plt>
mov    0x0(%rbp),%edi
call   1050 <fflush@plt>
mov    (%r12),%edx
mov    %rbx,%rdi
mov    $0xc8,%esi
call   1030 <fgets@plt>
test   %rax,%rax
jne    1180 <main+0x50>
xor    %eax,%eax
add    $0xc8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@stdin = global i32 0
@stdout = global i32 0
@.str = [12 x i8] c"stdout - %s\00"
@stderr = global i32 0
@.str.1 = [12 x i8] c"stderr - %s\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8
%7 = alloca i8
%8 = alloca i32
%9 = alloca [200 x i8]
%10 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i8 10, i8* %7
br label %11
11: ; preds = %2, %28
%12 = getelementptr inbounds [200 x i8], [200 x i8]* %9, i64 0, i64 0
%13 = load i32, i32* @stdin
%14 = call i32* @fgets(i8* %12, i32 200, i32 %13)
%15 = icmp eq i32* null, %14
br i1 %15, label %16, label %17
16: ; preds = %11
br label %34
17: ; preds = %11
%18 = load i32, i32* @stdout
%19 = getelementptr inbounds [200 x i8], [200 x i8]* %9, i64 0, i64 0
%20 = call i32 @fprintf(i32 %18, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* %19)
%21 = load i32, i32* @stdout
%22 = call i32 @fflush(i32 %21)
%23 = getelementptr inbounds [200 x i8], [200 x i8]* %9, i64 0, i64 0
%24 = load i32, i32* @stdin
%25 = call i32* @fgets(i8* %23, i32 200, i32 %24)
%26 = icmp eq i32* null, %25
br i1 %26, label %27, label %28
27: ; preds = %17
br label %34
28: ; preds = %17
%29 = load i32, i32* @stderr
%30 = getelementptr inbounds [200 x i8], [200 x i8]* %9, i64 0, i64 0
%31 = call i32 @fprintf(i32 %29, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i8* %30)
%32 = load i32, i32* @stderr
%33 = call i32 @fflush(i32 %32)
br label %11
34: ; preds = %27, %16
%35 = load i32, i32* %3
ret i32 %35
}

LLVM IR (-O2):
@stdin = global i32 0
@stdout = global i32 0
@.str = [12 x i8] c"stdout - %s\00"
@stderr = global i32 0
@.str.1 = [12 x i8] c"stderr - %s\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [200 x i8]
%4 = getelementptr inbounds [200 x i8], [200 x i8]* %3, i64 0, i64 0
%5 = load i32, i32* @stdin
%6 = call i32* @fgets(i8* %4, i32 200, i32 %5)
%7 = icmp eq i32* %6, null
br i1 %7, label %24, label %8
8: ; preds = %2, %16
%9 = load i32, i32* @stdout
%10 = call i32 @fprintf(i32 %9, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* %4)
%11 = load i32, i32* @stdout
%12 = call i32 @fflush(i32 %11)
%13 = load i32, i32* @stdin
%14 = call i32* @fgets(i8* %4, i32 200, i32 %13)
%15 = icmp eq i32* %14, null
br i1 %15, label %24, label %16
16: ; preds = %8
%17 = load i32, i32* @stderr
%18 = call i32 @fprintf(i32 %17, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i8* %4)
%19 = load i32, i32* @stderr
%20 = call i32 @fflush(i32 %19)
%21 = load i32, i32* @stdin
%22 = call i32* @fgets(i8* %4, i32 200, i32 %21)
%23 = icmp eq i32* %22, null
br i1 %23, label %24, label %8
24: ; preds = %8, %16, %2
ret i32 0
}