#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*/ exit(int);
int strlen(char *);
int write(int, char *, int);
int main(int argc, char **argv) {
  char *yes;
  static char y[] = "y";
  int n;
  yes = argc == 1 ? y : argv[1];
  n = strlen(yes);
  yes[n++] = '\n';
  while (write(1, yes, n) != -1) {
  }
  exit(1);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x1,-0x8(%rbp)
jne    1160 <main+0x30>
lea    0x2ee1(%rip),%rax
mov    %rax,-0x28(%rbp)
jmp    116c <main+0x3c>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%rax
mov    -0x1c(%rbp),%ecx
mov    %ecx,%edx
add    $0x1,%edx
mov    %edx,-0x1c(%rbp)
movslq %ecx,%rcx
movb   $0xa,(%rax,%rcx,1)
mov    -0x18(%rbp),%rsi
mov    -0x1c(%rbp),%edx
mov    $0x1,%edi
call   1030 <write@plt>
cmp    $0xffffffff,%eax
je     11b5 <main+0x85>
jmp    1196 <main+0x66>
mov    $0x1,%edi
call   1050 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
cmp    $0x1,%edi
jne    1141 <main+0x11>
lea    0x2ef9(%rip),%rbx
jmp    1145 <main+0x15>
mov    0x8(%rsi),%rbx
mov    %rbx,%rdi
call   1040 <strlen@plt>
mov    %eax,%ebp
cltq
add    $0x1,%ebp
movb   $0xa,(%rbx,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    $0x1,%edi
mov    %rbx,%rsi
mov    %ebp,%edx
call   1030 <write@plt>
cmp    $0xffffffff,%eax
jne    1160 <main+0x30>
mov    $0x1,%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@main.y = internal global [2 x i8] c"y\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = load i32, i32* %4
%9 = icmp eq i32 %8, 1
br i1 %9, label %10, label %11
10: ; preds = %2
br label %15
11: ; preds = %2
%12 = load i8**, i8*** %5
%13 = getelementptr inbounds i8*, i8** %12, i64 1
%14 = load i8*, i8** %13
br label %15
15: ; preds = %11, %10
%16 = phi i8* [ getelementptr inbounds ([2 x i8], [2 x i8]* @main.y, i64 0, i64 0), %10 ], [ %14, %11 ]
store i8* %16, i8** %6
%17 = load i8*, i8** %6
%18 = call i32 @strlen(i8* %17)
store i32 %18, i32* %7
%19 = load i8*, i8** %6
%20 = load i32, i32* %7
%21 = add nsw i32 %20, 1
store i32 %21, i32* %7
%22 = sext i32 %20 to i64
%23 = getelementptr inbounds i8, i8* %19, i64 %22
store i8 10, i8* %23
br label %24
24: ; preds = %29, %15
%25 = load i8*, i8** %6
%26 = load i32, i32* %7
%27 = call i32 @write(i32 1, i8* %25, i32 %26)
%28 = icmp ne i32 %27, -1
br i1 %28, label %29, label %30
29: ; preds = %24
br label %24
30: ; preds = %24
%31 = call i32 @exit(i32 1)
unreachable
}

LLVM IR (-O2):
@main.y = internal global [2 x i8] c"y\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 1
br i1 %3, label %7, label %4
4: ; preds = %2
%5 = getelementptr inbounds i8*, i8** %1, i64 1
%6 = load i8*, i8** %5
br label %7
7: ; preds = %2, %4
%8 = phi i8* [ %6, %4 ], [ getelementptr inbounds ([2 x i8], [2 x i8]* @main.y, i64 0, i64 0), %2 ]
%9 = tail call i32 @strlen(i8* %8)
%10 = add nsw i32 %9, 1
%11 = sext i32 %9 to i64
%12 = getelementptr inbounds i8, i8* %8, i64 %11
store i8 10, i8* %12
br label %13
13: ; preds = %13, %7
%14 = tail call i32 @write(i32 1, i8* %8, i32 %10)
%15 = icmp eq i32 %14, -1
br i1 %15, label %16, label %13
16: ; preds = %13
%17 = tail call i32 @exit(i32 1)
unreachable
}