#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*/ printf(char *, ...);
int /*<<< orphan*/ putchar(char);
int q1k() {
  char a[] = "goodbye!";
  char *p;
  printf("\n%s\n", "q1k ------");
  for (p = a; *p != 0; p += 2) {
    putchar(*p);
  }
  printf("\n");
  return 1;
}


x86 assembly (clang, -O0):
<q1k>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    0xed1(%rip),%rax
mov    %rax,-0x9(%rbp)
mov    0xecf(%rip),%al
mov    %al,-0x1(%rbp)
lea    0xec6(%rip),%rdi
lea    0xec4(%rip),%rsi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x9(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     1186 <q1k+0x66>
mov    -0x18(%rbp),%rax
movsbl (%rax),%edi
call   1030 <putchar@plt>
mov    -0x18(%rbp),%rax
add    $0x2,%rax
mov    %rax,-0x18(%rbp)
jmp    1159 <q1k+0x39>
lea    0xe7f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x1,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<q1k>:
push   %rbx
sub    $0x10,%rsp
movabs $0x21657962646f6f67,%rax
79 65 21
mov    %rax,(%rsp)
movb   $0x0,0x8(%rsp)
lea    0xeca(%rip),%rdi
lea    0xec8(%rip),%rsi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0x2(%rsp),%rbx
mov    $0x67,%al
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movsbl %al,%edi
call   1030 <putchar@plt>
movzbl (%rbx),%eax
add    $0x2,%rbx
test   %al,%al
jne    1160 <q1k+0x40>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    $0x1,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@__const.q1k.a = [9 x i8] c"goodbye!\00"
@.str = [5 x i8] c"\0A%s\0A\00"
@.str.1 = [11 x i8] c"q1k ------\00"
@.str.2 = [2 x i8] c"\0A\00"
define i32 @q1k() {
%1 = alloca [9 x i8]
%2 = alloca i8*
%3 = bitcast [9 x i8]* %1 to i8*
%4 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
%5 = getelementptr inbounds [9 x i8], [9 x i8]* %1, i64 0, i64 0
store i8* %5, i8** %2
br label %6
6: ; preds = %15, %0
%7 = load i8*, i8** %2
%8 = load i8, i8* %7
%9 = sext i8 %8 to i32
%10 = icmp ne i32 %9, 0
br i1 %10, label %11, label %18
11: ; preds = %6
%12 = load i8*, i8** %2
%13 = load i8, i8* %12
%14 = call i32 @putchar(i8 signext %13)
br label %15
15: ; preds = %11
%16 = load i8*, i8** %2
%17 = getelementptr inbounds i8, i8* %16, i64 2
store i8* %17, i8** %2
br label %6
18: ; preds = %6
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
ret i32 1
}

LLVM IR (-O2):
@__const.q1k.a = [9 x i8] c"goodbye!\00"
@.str = [5 x i8] c"\0A%s\0A\00"
@.str.1 = [11 x i8] c"q1k ------\00"
define i32 @q1k() {
%1 = alloca [9 x i8]
%2 = getelementptr inbounds [9 x i8], [9 x i8]* %1, i64 0, i64 0
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
br label %4
4: ; preds = %0, %4
%5 = phi i8 [ %9, %4 ], [ 103, %0 ]
%6 = phi i8* [ %8, %4 ], [ %2, %0 ]
%7 = tail call i32 @putchar(i8 signext %5)
%8 = getelementptr inbounds i8, i8* %6, i64 2
%9 = load i8, i8* %8
%10 = icmp eq i8 %9, 0
br i1 %10, label %11, label %4
11: ; preds = %4
%12 = tail call i32 bitcast (i32 (i8)* @putchar to i32 (i32)*)(i32 10)
ret i32 1
}