#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 */
char EOF;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ fflush(int /*<<< orphan*/ *);
char fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, unsigned int,
                           unsigned int);
char fputc(char, int /*<<< orphan*/ *);
int /*<<< orphan*/ *make_connection();
int /*<<< orphan*/ *stdout;
int initiate(unsigned int count, unsigned int delay) {
  FILE *stream;
  char c;
  stream = make_connection();
  if (!stream) {
    return 1;
  }
  fprintf(stream, "%u %u\n", count, delay);
  while (1) {
    fflush(stream);
    c = fgetc(stream);
    if (c == EOF) {
      break;
    }
    if (fputc(c, stdout) == EOF) {
      break;
    }
    fflush(stdout);
  }
  fclose(stream);
  return 0;
}


x86 assembly (clang, -O0):
<initiate>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    $0x0,%al
call   1080 <make_connection@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1190 <initiate+0x30>
movl   $0x1,-0x4(%rbp)
jmp    1229 <initiate+0xc9>
mov    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%edx
mov    -0xc(%rbp),%ecx
lea    0xe5f(%rip),%rsi
call   1060 <fprintf@plt>
mov    -0x18(%rbp),%rdi
call   1070 <fflush@plt>
mov    -0x18(%rbp),%rdi
call   1040 <fgetc@plt>
mov    %al,-0x19(%rbp)
movsbl -0x19(%rbp),%eax
mov    0x2e22(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
jne    11d6 <initiate+0x76>
jmp    1219 <initiate+0xb9>
mov    -0x19(%rbp),%al
mov    0x2df8(%rip),%rcx
mov    (%rcx),%rsi
movsbl %al,%edi
call   1050 <fputc@plt>
movsbl %al,%eax
mov    0x2df3(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
jne    1205 <initiate+0xa5>
jmp    1219 <initiate+0xb9>
mov    0x2dcc(%rip),%rax
mov    (%rax),%rdi
call   1070 <fflush@plt>
jmp    11a6 <initiate+0x46>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<initiate>:
push   %rbp
push   %r14
push   %rbx
mov    %esi,%r14d
mov    %edi,%ebp
xor    %eax,%eax
call   1080 <make_connection@plt>
test   %rax,%rax
je     11eb <initiate+0x8b>
mov    %rax,%rbx
lea    0xe81(%rip),%rsi
mov    %rax,%rdi
mov    %ebp,%edx
mov    %r14d,%ecx
call   1060 <fprintf@plt>
mov    %rbx,%rdi
call   1070 <fflush@plt>
mov    %rbx,%rdi
call   1040 <fgetc@plt>
mov    0x2e45(%rip),%r14
cmp    (%r14),%al
je     11df <initiate+0x7f>
mov    0x2e29(%rip),%rbp
nop
mov    0x0(%rbp),%rsi
movsbl %al,%edi
call   1050 <fputc@plt>
cmp    (%r14),%al
je     11df <initiate+0x7f>
mov    0x0(%rbp),%rdi
call   1070 <fflush@plt>
mov    %rbx,%rdi
call   1070 <fflush@plt>
mov    %rbx,%rdi
call   1040 <fgetc@plt>
cmp    (%r14),%al
jne    11b0 <initiate+0x50>
mov    %rbx,%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
jmp    11f0 <initiate+0x90>
mov    $0x1,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [7 x i8] c"%u %u\0A\00"
@EOF = global i8 0
@stdout = global i32* null
define i32 @initiate(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32*
%7 = alloca i8
store i32 %0, i32* %4
store i32 %1, i32* %5
%8 = call i32* (...) @make_connection()
store i32* %8, i32** %6
%9 = load i32*, i32** %6
%10 = icmp ne i32* %9, null
br i1 %10, label %12, label %11
11: ; preds = %2
store i32 1, i32* %3
br label %43
12: ; preds = %2
%13 = load i32*, i32** %6
%14 = load i32, i32* %4
%15 = load i32, i32* %5
%16 = call i32 @fprintf(i32* %13, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 %14, i32 %15)
br label %17
17: ; preds = %12, %37
%18 = load i32*, i32** %6
%19 = call i32 @fflush(i32* %18)
%20 = load i32*, i32** %6
%21 = call signext i8 @fgetc(i32* %20)
store i8 %21, i8* %7
%22 = load i8, i8* %7
%23 = sext i8 %22 to i32
%24 = load i8, i8* @EOF
%25 = sext i8 %24 to i32
%26 = icmp eq i32 %23, %25
br i1 %26, label %27, label %28
27: ; preds = %17
br label %40
28: ; preds = %17
%29 = load i8, i8* %7
%30 = load i32*, i32** @stdout
%31 = call signext i8 @fputc(i8 signext %29, i32* %30)
%32 = sext i8 %31 to i32
%33 = load i8, i8* @EOF
%34 = sext i8 %33 to i32
%35 = icmp eq i32 %32, %34
br i1 %35, label %36, label %37
36: ; preds = %28
br label %40
37: ; preds = %28
%38 = load i32*, i32** @stdout
%39 = call i32 @fflush(i32* %38)
br label %17
40: ; preds = %36, %27
%41 = load i32*, i32** %6
%42 = call i32 @fclose(i32* %41)
store i32 0, i32* %3
br label %43
43: ; preds = %40, %11
%44 = load i32, i32* %3
ret i32 %44
}

LLVM IR (-O2):
@.str = [7 x i8] c"%u %u\0A\00"
@EOF = global i8 0
@stdout = global i32* null
define i32 @initiate(i32 %0, i32 %1) {
%3 = tail call i32* (...) @make_connection()
%4 = icmp eq i32* %3, null
br i1 %4, label %26, label %5
5: ; preds = %2
%6 = tail call i32 @fprintf(i32* %3, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 %0, i32 %1)
%7 = tail call i32 @fflush(i32* %3)
%8 = tail call signext i8 @fgetc(i32* %3)
%9 = load i8, i8* @EOF
%10 = icmp eq i8 %8, %9
br i1 %10, label %24, label %11
11: ; preds = %5, %17
%12 = phi i8 [ %21, %17 ], [ %8, %5 ]
%13 = load i32*, i32** @stdout
%14 = tail call signext i8 @fputc(i8 signext %12, i32* %13)
%15 = load i8, i8* @EOF
%16 = icmp eq i8 %14, %15
br i1 %16, label %24, label %17
17: ; preds = %11
%18 = load i32*, i32** @stdout
%19 = tail call i32 @fflush(i32* %18)
%20 = tail call i32 @fflush(i32* %3)
%21 = tail call signext i8 @fgetc(i32* %3)
%22 = load i8, i8* @EOF
%23 = icmp eq i8 %21, %22
br i1 %23, label %24, label %11
24: ; preds = %17, %11, %5
%25 = tail call i32 @fclose(i32* %3)
br label %26
26: ; preds = %2, %24
%27 = phi i32 [ 0, %24 ], [ 1, %2 ]
ret i32 %27
}