#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 buf_put(char);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
int auto_putter() {
  char string[1024 + 1];
  int string_length;
  int return_value;
  int i;
  printf("auto_putter\n");
  strcpy(string, "Hello World! q");
  string_length = strlen(string);
  do {
    for (i = 0; (i < string_length); i++) {
      do {
        return_value = buf_put(string[i]);
        if ((return_value != 1) && (return_value != 0)) {
          return -1;
        }
      } while (return_value == 0);
      if ((string[i] == 'q') || (string[i] == 'Q')) {
        break;
      }
    }
  } while ((string[i] != 'q') && (string[i] != 'Q'));
  return 0;
}


x86 assembly (clang, -O0):
<auto_putter>:
push   %rbp
mov    %rsp,%rbp
sub    $0x420,%rsp
lea    0xeae(%rip),%rdi
call   1050 <printf@plt>
lea    -0x410(%rbp),%rdi
lea    0xea8(%rip),%rsi
call   1030 <strcpy@plt>
lea    -0x410(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x414(%rbp)
movl   $0x0,-0x41c(%rbp)
mov    -0x41c(%rbp),%eax
cmp    -0x414(%rbp),%eax
jge    123d <auto_putter+0xfd>
jmp    119d <auto_putter+0x5d>
movslq -0x41c(%rbp),%rax
movsbl -0x410(%rbp,%rax,1),%edi
ff
call   1060 <buf_put@plt>
mov    %eax,-0x418(%rbp)
cmpl   $0x1,-0x418(%rbp)
je     11dd <auto_putter+0x9d>
cmpl   $0x0,-0x418(%rbp)
je     11dd <auto_putter+0x9d>
movl   $0xffffffff,-0x4(%rbp)
jmp    1292 <auto_putter+0x152>
jmp    11e2 <auto_putter+0xa2>
cmpl   $0x0,-0x418(%rbp)
je     119d <auto_putter+0x5d>
movslq -0x41c(%rbp),%rax
movsbl -0x410(%rbp,%rax,1),%eax
ff
cmp    $0x71,%eax
je     121f <auto_putter+0xdf>
movslq -0x41c(%rbp),%rax
movsbl -0x410(%rbp,%rax,1),%eax
ff
cmp    $0x51,%eax
jne    1224 <auto_putter+0xe4>
jmp    123d <auto_putter+0xfd>
jmp    1229 <auto_putter+0xe9>
mov    -0x41c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x41c(%rbp)
jmp    1186 <auto_putter+0x46>
jmp    1242 <auto_putter+0x102>
movslq -0x41c(%rbp),%rax
movsbl -0x410(%rbp,%rax,1),%ecx
ff
xor    %eax,%eax
cmp    $0x71,%ecx
mov    %al,-0x41d(%rbp)
je     127d <auto_putter+0x13d>
movslq -0x41c(%rbp),%rax
movsbl -0x410(%rbp,%rax,1),%eax
ff
cmp    $0x51,%eax
setne  %al
mov    %al,-0x41d(%rbp)
mov    -0x41d(%rbp),%al
test   $0x1,%al
jne    117c <auto_putter+0x3c>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x420,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<auto_putter>:
push   %rbp
push   %r14
push   %rbx
sub    $0x410,%rsp
lea    0xebd(%rip),%rdi
call   1040 <puts@plt>
lea    0xea2(%rip),%rsi
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1030 <strcpy@plt>
mov    %rbx,%rdi
call   1050 <strlen@plt>
mov    %eax,%ebp
mov    %eax,%r14d
mov    $0x0,%ebx
test   %ebp,%ebp
jle    11c0 <auto_putter+0x80>
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movsbl (%rsp,%rbx,1),%edi
call   1060 <buf_put@plt>
cmp    $0x1,%eax
ja     11cf <auto_putter+0x8f>
test   %eax,%eax
je     1190 <auto_putter+0x50>
movzbl (%rsp,%rbx,1),%eax
or     $0x20,%al
cmp    $0x71,%al
je     11c0 <auto_putter+0x80>
add    $0x1,%rbx
cmp    %r14,%rbx
jne    1190 <auto_putter+0x50>
mov    %ebp,%ebx
nopw   0x0(%rax,%rax,1)
mov    %ebx,%eax
mov    (%rsp,%rax,1),%al
or     $0x20,%al
cmp    $0x71,%al
jne    1176 <auto_putter+0x36>
xor    %eax,%eax
jmp    11d4 <auto_putter+0x94>
mov    $0xffffffff,%eax
add    $0x410,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [13 x i8] c"auto_putter\0A\00"
@.str.1 = [15 x i8] c"Hello World! q\00"
define i32 @auto_putter() {
%1 = alloca i32
%2 = alloca [1025 x i8]
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%7 = getelementptr inbounds [1025 x i8], [1025 x i8]* %2, i64 0, i64 0
%8 = call i32 @strcpy(i8* %7, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0))
%9 = getelementptr inbounds [1025 x i8], [1025 x i8]* %2, i64 0, i64 0
%10 = call i32 @strlen(i8* %9)
store i32 %10, i32* %3
br label %11
11: ; preds = %67, %0
store i32 0, i32* %5
br label %12
12: ; preds = %49, %11
%13 = load i32, i32* %5
%14 = load i32, i32* %3
%15 = icmp slt i32 %13, %14
br i1 %15, label %16, label %52
16: ; preds = %12
br label %17
17: ; preds = %30, %16
%18 = load i32, i32* %5
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds [1025 x i8], [1025 x i8]* %2, i64 0, i64 %19
%21 = load i8, i8* %20
%22 = call i32 @buf_put(i8 signext %21)
store i32 %22, i32* %4
%23 = load i32, i32* %4
%24 = icmp ne i32 %23, 1
br i1 %24, label %25, label %29
25: ; preds = %17
%26 = load i32, i32* %4
%27 = icmp ne i32 %26, 0
br i1 %27, label %28, label %29
28: ; preds = %25
store i32 -1, i32* %1
br label %70
29: ; preds = %25, %17
br label %30
30: ; preds = %29
%31 = load i32, i32* %4
%32 = icmp eq i32 %31, 0
br i1 %32, label %17, label %33
33: ; preds = %30
%34 = load i32, i32* %5
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds [1025 x i8], [1025 x i8]* %2, i64 0, i64 %35
%37 = load i8, i8* %36
%38 = sext i8 %37 to i32
%39 = icmp eq i32 %38, 113
br i1 %39, label %47, label %40
40: ; preds = %33
%41 = load i32, i32* %5
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds [1025 x i8], [1025 x i8]* %2, i64 0, i64 %42
%44 = load i8, i8* %43
%45 = sext i8 %44 to i32
%46 = icmp eq i32 %45, 81
br i1 %46, label %47, label %48
47: ; preds = %40, %33
br label %52
48: ; preds = %40
br label %49
49: ; preds = %48
%50 = load i32, i32* %5
%51 = add nsw i32 %50, 1
store i32 %51, i32* %5
br label %12
52: ; preds = %47, %12
br label %53
53: ; preds = %52
%54 = load i32, i32* %5
%55 = sext i32 %54 to i64
%56 = getelementptr inbounds [1025 x i8], [1025 x i8]* %2, i64 0, i64 %55
%57 = load i8, i8* %56
%58 = sext i8 %57 to i32
%59 = icmp ne i32 %58, 113
br i1 %59, label %60, label %67
60: ; preds = %53
%61 = load i32, i32* %5
%62 = sext i32 %61 to i64
%63 = getelementptr inbounds [1025 x i8], [1025 x i8]* %2, i64 0, i64 %62
%64 = load i8, i8* %63
%65 = sext i8 %64 to i32
%66 = icmp ne i32 %65, 81
br label %67
67: ; preds = %60, %53
%68 = phi i1 [ false, %53 ], [ %66, %60 ]
br i1 %68, label %11, label %69
69: ; preds = %67
store i32 0, i32* %1
br label %70
70: ; preds = %69, %28
%71 = load i32, i32* %1
ret i32 %71
}

LLVM IR (-O2):
@.str.1 = [15 x i8] c"Hello World! q\00"
@str = [12 x i8] c"auto_putter\00"
define i32 @auto_putter() {
%1 = alloca [1025 x i8]
%2 = getelementptr inbounds [1025 x i8], [1025 x i8]* %1, i64 0, i64 0
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str, i64 0, i64 0))
%4 = call i32 @strcpy(i8* %2, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0))
%5 = call i32 @strlen(i8* %2)
%6 = icmp sgt i32 %5, 0
%7 = zext i32 %5 to i64
br label %8
8: ; preds = %25, %0
br i1 %6, label %9, label %25
9: ; preds = %8, %20
%10 = phi i64 [ %21, %20 ], [ 0, %8 ]
%11 = getelementptr inbounds [1025 x i8], [1025 x i8]* %1, i64 0, i64 %10
br label %12
12: ; preds = %9, %16
%13 = load i8, i8* %11
%14 = call i32 @buf_put(i8 signext %13)
%15 = icmp ult i32 %14, 2
br i1 %15, label %16, label %30
16: ; preds = %12
%17 = icmp eq i32 %14, 0
br i1 %17, label %12, label %18
18: ; preds = %16
%19 = load i8, i8* %11
switch i8 %19, label %20 [
i8 113, label %23
i8 81, label %23
]
20: ; preds = %18
%21 = add nuw nsw i64 %10, 1
%22 = icmp eq i64 %21, %7
br i1 %22, label %25, label %9
23: ; preds = %18, %18
%24 = trunc i64 %10 to i32
br label %25
25: ; preds = %20, %23, %8
%26 = phi i32 [ 0, %8 ], [ %24, %23 ], [ %5, %20 ]
%27 = zext i32 %26 to i64
%28 = getelementptr inbounds [1025 x i8], [1025 x i8]* %1, i64 0, i64 %27
%29 = load i8, i8* %28
switch i8 %29, label %8 [
i8 113, label %30
i8 81, label %30
]
30: ; preds = %25, %25, %12
%31 = phi i32 [ -1, %12 ], [ 0, %25 ], [ 0, %25 ]
ret i32 %31
}