#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 */
scalar_t__ bu_handle_version(int, char **);
int /*<<< orphan*/ fputs(char *, int /*<<< orphan*/);
scalar_t__ has_arg(int, char **, char *);
int /*<<< orphan*/ puts(char *);
int /*<<< orphan*/ stdout;
int main(int argc, char **argv) {
  if (has_arg(argc, argv, "-h") || has_arg(argc, argv, "--help")) {
    puts("Usage: yes [STRING]");
    puts("Print a string repeatedly until killed\n");
    puts("Options:");
    puts("  STRING    string to print (default: \"y\"");
    return 1;
  }
  if (bu_handle_version(argc, argv)) {
    return 0;
  }
  int testing = 0;
  if (has_arg(argc, argv, "-Wtesting")) {
    testing = 1;
  }
  while (1) {
    if (testing) {
      if (testing > 3) {
        return 0;
      }
      testing++;
    }
    if ((argc == 1) || (argc == 2 && testing)) {
      puts("y");
      continue;
    }
    for (int i = 1; i < argc - 1; i++) {
      fputs(argv[i], stdout);
      fputs(" ", stdout);
    }
    puts(argv[argc - 1]);
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xe9c(%rip),%rdx
call   1040 <has_arg@plt>
cmp    $0x0,%rax
jne    1190 <main+0x50>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xe82(%rip),%rdx
call   1040 <has_arg@plt>
cmp    $0x0,%rax
je     11cc <main+0x8c>
lea    0xe73(%rip),%rdi
call   1030 <puts@plt>
lea    0xe7b(%rip),%rdi
call   1030 <puts@plt>
lea    0xe97(%rip),%rdi
call   1030 <puts@plt>
lea    0xe94(%rip),%rdi
call   1030 <puts@plt>
movl   $0x1,-0x4(%rbp)
jmp    12e6 <main+0x1a6>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1060 <bu_handle_version@plt>
cmp    $0x0,%rax
je     11ee <main+0xae>
movl   $0x0,-0x4(%rbp)
jmp    12e6 <main+0x1a6>
movl   $0x0,-0x14(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xe76(%rip),%rdx
call   1040 <has_arg@plt>
cmp    $0x0,%rax
je     1219 <main+0xd9>
movl   $0x1,-0x14(%rbp)
jmp    121e <main+0xde>
cmpl   $0x0,-0x14(%rbp)
je     1247 <main+0x107>
cmpl   $0x3,-0x14(%rbp)
jle    123e <main+0xfe>
movl   $0x0,-0x4(%rbp)
jmp    12e6 <main+0x1a6>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
cmpl   $0x1,-0x8(%rbp)
je     1265 <main+0x125>
cmpl   $0x2,-0x8(%rbp)
jne    1276 <main+0x136>
cmpl   $0x0,-0x14(%rbp)
je     1276 <main+0x136>
lea    0xe17(%rip),%rdi
call   1030 <puts@plt>
jmp    121e <main+0xde>
movl   $0x1,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    -0x8(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    12cb <main+0x18b>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
mov    0x2d3f(%rip),%rax
mov    (%rax),%esi
call   1050 <fputs@plt>
mov    0x2d31(%rip),%rax
mov    (%rax),%esi
lea    0xdcd(%rip),%rdi
call   1050 <fputs@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    127d <main+0x13d>
mov    -0x10(%rbp),%rax
mov    -0x8(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rdi
call   1030 <puts@plt>
jmp    121e <main+0xde>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%r12
mov    %edi,%r14d
lea    0xea5(%rip),%rdx
call   1040 <has_arg@plt>
test   %rax,%rax
jne    117c <main+0x3c>
lea    0xe97(%rip),%rdx
mov    %r14d,%edi
mov    %r12,%rsi
call   1040 <has_arg@plt>
test   %rax,%rax
je     11c0 <main+0x80>
lea    0xe87(%rip),%rdi
call   1030 <puts@plt>
lea    0xe8f(%rip),%rdi
call   1030 <puts@plt>
lea    0xeab(%rip),%rdi
call   1030 <puts@plt>
lea    0xea8(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %r14d,%edi
mov    %r12,%rsi
call   1060 <bu_handle_version@plt>
mov    %rax,%rcx
xor    %eax,%eax
test   %rcx,%rcx
jne    11b1 <main+0x71>
lea    0xe9d(%rip),%rdx
mov    %r14d,%edi
mov    %r12,%rsi
call   1040 <has_arg@plt>
xor    %ebp,%ebp
test   %rax,%rax
setne  %bpl
lea    -0x1(%r14),%ebx
movslq %ebx,%rax
mov    %rax,0x8(%rsp)
mov    0x2ddd(%rip),%r13
lea    0xe7b(%rip),%r15
mov    %r14,0x10(%rsp)
jmp    1233 <main+0xf3>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    0x8(%rsp),%rax
mov    (%r12,%rax,8),%rdi
mov    0x10(%rsp),%r14
call   1030 <puts@plt>
test   %ebp,%ebp
je     1250 <main+0x110>
cmp    $0x3,%ebp
jg     12a7 <main+0x167>
add    $0x1,%ebp
jmp    1252 <main+0x112>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
xor    %ebp,%ebp
lea    0xe2a(%rip),%rdi
cmp    $0x1,%r14d
je     122e <main+0xee>
cmp    $0x2,%r14d
jne    1270 <main+0x130>
lea    0xe17(%rip),%rdi
test   %ebp,%ebp
jne    122e <main+0xee>
cmp    $0x3,%r14d
jl     1220 <main+0xe0>
mov    $0x1,%r14d
nopl   0x0(%rax)
mov    (%r12,%r14,8),%rdi
mov    0x0(%r13),%esi
call   1050 <fputs@plt>
mov    0x0(%r13),%esi
mov    %r15,%rdi
call   1050 <fputs@plt>
add    $0x1,%r14
cmp    %r14,%rbx
jne    1280 <main+0x140>
jmp    1220 <main+0xe0>
xor    %eax,%eax
jmp    11b1 <main+0x71>

LLVM IR (-O0):
@.str = [3 x i8] c"-h\00"
@.str.1 = [7 x i8] c"--help\00"
@.str.2 = [20 x i8] c"Usage: yes [STRING]\00"
@.str.3 = [40 x i8] c"Print a string repeatedly until killed\0A\00"
@.str.4 = [9 x i8] c"Options:\00"
@.str.5 = [42 x i8] c" STRING string to print (default: \22y\22\00"
@.str.6 = [10 x i8] c"-Wtesting\00"
@.str.7 = [2 x i8] c"y\00"
@stdout = global i32 0
@.str.8 = [2 x i8] c" \00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = load i32, i32* %4
%9 = load i8**, i8*** %5
%10 = call i64 @has_arg(i32 %8, i8** %9, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%11 = icmp ne i64 %10, 0
br i1 %11, label %17, label %12
12: ; preds = %2
%13 = load i32, i32* %4
%14 = load i8**, i8*** %5
%15 = call i64 @has_arg(i32 %13, i8** %14, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%16 = icmp ne i64 %15, 0
br i1 %16, label %17, label %22
17: ; preds = %12, %2
%18 = call i32 @puts(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0))
%19 = call i32 @puts(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.3, i64 0, i64 0))
%20 = call i32 @puts(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0))
%21 = call i32 @puts(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.5, i64 0, i64 0))
store i32 1, i32* %3
br label %83
22: ; preds = %12
%23 = load i32, i32* %4
%24 = load i8**, i8*** %5
%25 = call i64 @bu_handle_version(i32 %23, i8** %24)
%26 = icmp ne i64 %25, 0
br i1 %26, label %27, label %28
27: ; preds = %22
store i32 0, i32* %3
br label %83
28: ; preds = %22
store i32 0, i32* %6
%29 = load i32, i32* %4
%30 = load i8**, i8*** %5
%31 = call i64 @has_arg(i32 %29, i8** %30, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i64 0, i64 0))
%32 = icmp ne i64 %31, 0
br i1 %32, label %33, label %34
33: ; preds = %28
store i32 1, i32* %6
br label %34
34: ; preds = %33, %28
br label %35
35: ; preds = %34, %54, %75
%36 = load i32, i32* %6
%37 = icmp ne i32 %36, 0
br i1 %37, label %38, label %45
38: ; preds = %35
%39 = load i32, i32* %6
%40 = icmp sgt i32 %39, 3
br i1 %40, label %41, label %42
41: ; preds = %38
store i32 0, i32* %3
br label %83
42: ; preds = %38
%43 = load i32, i32* %6
%44 = add nsw i32 %43, 1
store i32 %44, i32* %6
br label %45
45: ; preds = %42, %35
%46 = load i32, i32* %4
%47 = icmp eq i32 %46, 1
br i1 %47, label %54, label %48
48: ; preds = %45
%49 = load i32, i32* %4
%50 = icmp eq i32 %49, 2
br i1 %50, label %51, label %56
51: ; preds = %48
%52 = load i32, i32* %6
%53 = icmp ne i32 %52, 0
br i1 %53, label %54, label %56
54: ; preds = %51, %45
%55 = call i32 @puts(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
br label %35
56: ; preds = %51, %48
store i32 1, i32* %7
br label %57
57: ; preds = %72, %56
%58 = load i32, i32* %7
%59 = load i32, i32* %4
%60 = sub nsw i32 %59, 1
%61 = icmp slt i32 %58, %60
br i1 %61, label %62, label %75
62: ; preds = %57
%63 = load i8**, i8*** %5
%64 = load i32, i32* %7
%65 = sext i32 %64 to i64
%66 = getelementptr inbounds i8*, i8** %63, i64 %65
%67 = load i8*, i8** %66
%68 = load i32, i32* @stdout
%69 = call i32 @fputs(i8* %67, i32 %68)
%70 = load i32, i32* @stdout
%71 = call i32 @fputs(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0), i32 %70)
br label %72
72: ; preds = %62
%73 = load i32, i32* %7
%74 = add nsw i32 %73, 1
store i32 %74, i32* %7
br label %57
75: ; preds = %57
%76 = load i8**, i8*** %5
%77 = load i32, i32* %4
%78 = sub nsw i32 %77, 1
%79 = sext i32 %78 to i64
%80 = getelementptr inbounds i8*, i8** %76, i64 %79
%81 = load i8*, i8** %80
%82 = call i32 @puts(i8* %81)
br label %35
83: ; preds = %41, %27, %17
%84 = load i32, i32* %3
ret i32 %84
}

LLVM IR (-O2):
@.str = [3 x i8] c"-h\00"
@.str.1 = [7 x i8] c"--help\00"
@.str.2 = [20 x i8] c"Usage: yes [STRING]\00"
@.str.3 = [40 x i8] c"Print a string repeatedly until killed\0A\00"
@.str.4 = [9 x i8] c"Options:\00"
@.str.5 = [42 x i8] c" STRING string to print (default: \22y\22\00"
@.str.6 = [10 x i8] c"-Wtesting\00"
@.str.7 = [2 x i8] c"y\00"
@stdout = global i32 0
@.str.8 = [2 x i8] c" \00"
define i32 @main(i32 %0, i8** %1) {
%3 = tail call i64 @has_arg(i32 %0, i8** %1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%4 = icmp eq i64 %3, 0
br i1 %4, label %5, label %8
5: ; preds = %2
%6 = tail call i64 @has_arg(i32 %0, i8** %1, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%7 = icmp eq i64 %6, 0
br i1 %7, label %13, label %8
8: ; preds = %5, %2
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0))
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @.str.3, i64 0, i64 0))
%11 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0))
%12 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @.str.5, i64 0, i64 0))
br label %55
13: ; preds = %5
%14 = tail call i64 @bu_handle_version(i32 %0, i8** %1)
%15 = icmp eq i64 %14, 0
br i1 %15, label %16, label %55
16: ; preds = %13
%17 = tail call i64 @has_arg(i32 %0, i8** %1, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i64 0, i64 0))
%18 = icmp ne i64 %17, 0
%19 = zext i1 %18 to i32
%20 = icmp eq i32 %0, 1
%21 = icmp eq i32 %0, 2
%22 = add i32 %0, -1
%23 = icmp sgt i32 %0, 2
%24 = sext i32 %22 to i64
%25 = getelementptr inbounds i8*, i8** %1, i64 %24
%26 = zext i32 %22 to i64
br label %27
27: ; preds = %40, %16
%28 = phi i32 [ %19, %16 ], [ %35, %40 ]
%29 = icmp eq i32 %28, 0
br i1 %29, label %34, label %30
30: ; preds = %27
%31 = icmp sgt i32 %28, 3
br i1 %31, label %55, label %32
32: ; preds = %30
%33 = add nsw i32 %28, 1
br label %34
34: ; preds = %32, %27
%35 = phi i32 [ %33, %32 ], [ 0, %27 ]
br i1 %20, label %40, label %36
36: ; preds = %34
%37 = icmp ne i32 %35, 0
%38 = select i1 %21, i1 %37, i1 false
br i1 %38, label %40, label %39
39: ; preds = %36
br i1 %23, label %45, label %43
40: ; preds = %34, %36, %43
%41 = phi i8* [ %44, %43 ], [ getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0), %36 ], [ getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0), %34 ]
%42 = tail call i32 @puts(i8* dereferenceable(1) %41)
br label %27
43: ; preds = %45, %39
%44 = load i8*, i8** %25
br label %40
45: ; preds = %39, %45
%46 = phi i64 [ %53, %45 ], [ 1, %39 ]
%47 = getelementptr inbounds i8*, i8** %1, i64 %46
%48 = load i8*, i8** %47
%49 = load i32, i32* @stdout
%50 = tail call i32 @fputs(i8* %48, i32 %49)
%51 = load i32, i32* @stdout
%52 = tail call i32 @fputs(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0), i32 %51)
%53 = add nuw nsw i64 %46, 1
%54 = icmp eq i64 %53, %26
br i1 %54, label %43, label %45
55: ; preds = %30, %13, %8
%56 = phi i32 [ 1, %8 ], [ 0, %13 ], [ 0, %30 ]
ret i32 %56
}