#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 main(void) {
  char str[] = "you are a girl";
  char *p;
  printf("can it end with 'nul' or '0' of its ASCII code\n");
  for (p = str; *p; p++) {
    putchar(*p);
  }
  printf("\n\t*\t*\t*\n");
  printf("can it end with null\n");
  int i = 0;
  for (p = str; i < 20 && p != NULL; p++, i++) {
    putchar(*p);
  }
  printf("\n\t*\t*\t*\t*\t*\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xeca(%rip),%rax
mov    %rax,-0x13(%rbp)
mov    0xec8(%rip),%eax
mov    %eax,-0xb(%rbp)
mov    0xec2(%rip),%ax
mov    %ax,-0x7(%rbp)
mov    0xeba(%rip),%al
mov    %al,-0x5(%rbp)
lea    0xeb1(%rip),%rdi
call   1040 <printf@plt>
lea    -0x13(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
cmpb   $0x0,(%rax)
je     1195 <main+0x75>
mov    -0x20(%rbp),%rax
movsbl (%rax),%edi
call   1030 <putchar@plt>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    116b <main+0x4b>
lea    0xea3(%rip),%rdi
call   1040 <printf@plt>
lea    0xea0(%rip),%rdi
call   1040 <printf@plt>
movl   $0x0,-0x24(%rbp)
lea    -0x13(%rbp),%rax
mov    %rax,-0x20(%rbp)
xor    %eax,%eax
cmpl   $0x14,-0x24(%rbp)
mov    %al,-0x25(%rbp)
jge    11d6 <main+0xb6>
cmpq   $0x0,-0x20(%rbp)
setne  %al
mov    %al,-0x25(%rbp)
mov    -0x25(%rbp),%al
test   $0x1,%al
jne    11e6 <main+0xc6>
jmp    120c <main+0xec>
mov    -0x20(%rbp),%rax
movsbl (%rax),%edi
call   1030 <putchar@plt>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    11bc <main+0x9c>
lea    0xe4b(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
movabs $0x6c726967206120,%rax
mov    %rax,0x7(%rsp)
movabs $0x2065726120756f79,%rax
72 65 20
mov    %rax,(%rsp)
lea    0xec6(%rip),%rdi
call   1040 <puts@plt>
lea    0x1(%rsp),%rbx
mov    $0x79,%al
cs nopw 0x0(%rax,%rax,1)
nop
movsbl %al,%edi
call   1030 <putchar@plt>
movzbl (%rbx),%eax
add    $0x1,%rbx
test   %al,%al
jne    1160 <main+0x40>
lea    0xec4(%rip),%rdi
call   1040 <puts@plt>
lea    0xec0(%rip),%rdi
call   1040 <puts@plt>
mov    $0x79,%edi
call   1030 <putchar@plt>
mov    $0x6f,%edi
call   1030 <putchar@plt>
mov    $0x75,%edi
call   1030 <putchar@plt>
mov    $0x20,%edi
call   1030 <putchar@plt>
mov    $0x61,%edi
call   1030 <putchar@plt>
mov    $0x72,%edi
call   1030 <putchar@plt>
movsbl 0x6(%rsp),%edi
call   1030 <putchar@plt>
movsbl 0x7(%rsp),%edi
call   1030 <putchar@plt>
movsbl 0x8(%rsp),%edi
call   1030 <putchar@plt>
movsbl 0x9(%rsp),%edi
call   1030 <putchar@plt>
movsbl 0xa(%rsp),%edi
call   1030 <putchar@plt>
movsbl 0xb(%rsp),%edi
call   1030 <putchar@plt>
movsbl 0xc(%rsp),%edi
call   1030 <putchar@plt>
movsbl 0xd(%rsp),%edi
call   1030 <putchar@plt>
movsbl 0xe(%rsp),%edi
call   1030 <putchar@plt>
movsbl 0xf(%rsp),%edi
call   1030 <putchar@plt>
movsbl 0x10(%rsp),%edi
call   1030 <putchar@plt>
movsbl 0x11(%rsp),%edi
call   1030 <putchar@plt>
movsbl 0x12(%rsp),%edi
call   1030 <putchar@plt>
movsbl 0x13(%rsp),%edi
call   1030 <putchar@plt>
lea    0xe01(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@__const.main.str = [15 x i8] c"you are a girl\00"
@.str = [48 x i8] c"can it end with 'nul' or '0' of its ASCII code\0A\00"
@.str.1 = [9 x i8] c"\0A\09*\09*\09*\0A\00"
@.str.2 = [22 x i8] c"can it end with null\0A\00"
@.str.3 = [13 x i8] c"\0A\09*\09*\09*\09*\09*\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [15 x i8]
%3 = alloca i8*
%4 = alloca i32
store i32 0, i32* %1
%5 = bitcast [15 x i8]* %2 to i8*
%6 = call i32 @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str, i64 0, i64 0))
%7 = getelementptr inbounds [15 x i8], [15 x i8]* %2, i64 0, i64 0
store i8* %7, i8** %3
br label %8
8: ; preds = %16, %0
%9 = load i8*, i8** %3
%10 = load i8, i8* %9
%11 = icmp ne i8 %10, 0
br i1 %11, label %12, label %19
12: ; preds = %8
%13 = load i8*, i8** %3
%14 = load i8, i8* %13
%15 = call i32 @putchar(i8 signext %14)
br label %16
16: ; preds = %12
%17 = load i8*, i8** %3
%18 = getelementptr inbounds i8, i8* %17, i32 1
store i8* %18, i8** %3
br label %8
19: ; preds = %8
%20 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%21 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %4
%22 = getelementptr inbounds [15 x i8], [15 x i8]* %2, i64 0, i64 0
store i8* %22, i8** %3
br label %23
23: ; preds = %35, %19
%24 = load i32, i32* %4
%25 = icmp slt i32 %24, 20
br i1 %25, label %26, label %29
26: ; preds = %23
%27 = load i8*, i8** %3
%28 = icmp ne i8* %27, null
br label %29
29: ; preds = %26, %23
%30 = phi i1 [ false, %23 ], [ %28, %26 ]
br i1 %30, label %31, label %40
31: ; preds = %29
%32 = load i8*, i8** %3
%33 = load i8, i8* %32
%34 = call i32 @putchar(i8 signext %33)
br label %35
35: ; preds = %31
%36 = load i8*, i8** %3
%37 = getelementptr inbounds i8, i8* %36, i32 1
store i8* %37, i8** %3
%38 = load i32, i32* %4
%39 = add nsw i32 %38, 1
store i32 %39, i32* %4
br label %23
40: ; preds = %29
%41 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@__const.main.str = [15 x i8] c"you are a girl\00"
@str = [47 x i8] c"can it end with 'nul' or '0' of its ASCII code\00"
@str.4 = [8 x i8] c"\0A\09*\09*\09*\00"
@str.5 = [21 x i8] c"can it end with null\00"
@str.6 = [12 x i8] c"\0A\09*\09*\09*\09*\09*\00"
define i32 @main() {
%1 = alloca [15 x i8]
%2 = getelementptr inbounds [15 x i8], [15 x i8]* %1, i64 0, i64 0
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([47 x i8], [47 x i8]* @str, i64 0, i64 0))
br label %4
4: ; preds = %0, %4
%5 = phi i8 [ %9, %4 ], [ 121, %0 ]
%6 = phi i8* [ %8, %4 ], [ %2, %0 ]
%7 = tail call i32 @putchar(i8 signext %5)
%8 = getelementptr inbounds i8, i8* %6, i64 1
%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 @puts(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @str.4, i64 0, i64 0))
%13 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str.5, i64 0, i64 0))
%14 = tail call i32 @putchar(i8 signext 121)
%15 = tail call i32 @putchar(i8 signext 111)
%16 = tail call i32 @putchar(i8 signext 117)
%17 = tail call i32 @putchar(i8 signext 32)
%18 = tail call i32 @putchar(i8 signext 97)
%19 = tail call i32 @putchar(i8 signext 114)
%20 = getelementptr inbounds [15 x i8], [15 x i8]* %1, i64 0, i64 6
%21 = load i8, i8* %20
%22 = tail call i32 @putchar(i8 signext %21)
%23 = getelementptr inbounds [15 x i8], [15 x i8]* %1, i64 0, i64 7
%24 = load i8, i8* %23
%25 = tail call i32 @putchar(i8 signext %24)
%26 = getelementptr inbounds [15 x i8], [15 x i8]* %1, i64 0, i64 8
%27 = load i8, i8* %26
%28 = tail call i32 @putchar(i8 signext %27)
%29 = getelementptr inbounds [15 x i8], [15 x i8]* %1, i64 0, i64 9
%30 = load i8, i8* %29
%31 = tail call i32 @putchar(i8 signext %30)
%32 = getelementptr inbounds [15 x i8], [15 x i8]* %1, i64 0, i64 10
%33 = load i8, i8* %32
%34 = tail call i32 @putchar(i8 signext %33)
%35 = getelementptr inbounds [15 x i8], [15 x i8]* %1, i64 0, i64 11
%36 = load i8, i8* %35
%37 = tail call i32 @putchar(i8 signext %36)
%38 = getelementptr inbounds [15 x i8], [15 x i8]* %1, i64 0, i64 12
%39 = load i8, i8* %38
%40 = tail call i32 @putchar(i8 signext %39)
%41 = getelementptr inbounds [15 x i8], [15 x i8]* %1, i64 0, i64 13
%42 = load i8, i8* %41
%43 = tail call i32 @putchar(i8 signext %42)
%44 = getelementptr inbounds [15 x i8], [15 x i8]* %1, i64 0, i64 14
%45 = load i8, i8* %44
%46 = tail call i32 @putchar(i8 signext %45)
%47 = getelementptr inbounds [15 x i8], [15 x i8]* %1, i64 0, i64 15
%48 = load i8, i8* %47
%49 = tail call i32 @putchar(i8 signext %48)
%50 = getelementptr inbounds [15 x i8], [15 x i8]* %1, i64 0, i64 16
%51 = load i8, i8* %50
%52 = tail call i32 @putchar(i8 signext %51)
%53 = getelementptr inbounds [15 x i8], [15 x i8]* %1, i64 0, i64 17
%54 = load i8, i8* %53
%55 = tail call i32 @putchar(i8 signext %54)
%56 = getelementptr inbounds [15 x i8], [15 x i8]* %1, i64 0, i64 18
%57 = load i8, i8* %56
%58 = tail call i32 @putchar(i8 signext %57)
%59 = getelementptr inbounds [15 x i8], [15 x i8]* %1, i64 0, i64 19
%60 = load i8, i8* %59
%61 = tail call i32 @putchar(i8 signext %60)
%62 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str.6, i64 0, i64 0))
ret i32 0
}