#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 main(int argc, char **argv) {
  char s[] = {'s', 't', 'r', 'i', 'n', 'g', 0};
  printf("string is %s\n", s);
  for (int i = 0; s[i] != 0; i++) {
    printf("char is: %c\n", s[i]);
  }
  printf("\n");
  for (char *cp = s; *cp; ++cp) {
    printf("char is: %c\n", *cp);
  }
  return 0;
}


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)
mov    0xed4(%rip),%eax
mov    %eax,-0x17(%rbp)
mov    0xece(%rip),%ax
mov    %ax,-0x13(%rbp)
mov    0xec6(%rip),%al
mov    %al,-0x11(%rbp)
lea    -0x17(%rbp),%rsi
lea    0xeb9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x1c(%rbp)
movslq -0x1c(%rbp),%rax
movsbl -0x17(%rbp,%rax,1),%eax
cmp    $0x0,%eax
je     1193 <main+0x83>
movslq -0x1c(%rbp),%rax
movsbl -0x17(%rbp,%rax,1),%esi
lea    0xe97(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    115c <main+0x4c>
lea    0xe86(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x17(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
cmpb   $0x0,(%rax)
je     11dc <main+0xcc>
mov    -0x28(%rbp),%rax
movsbl (%rax),%esi
lea    0xe51(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
jmp    11a9 <main+0x99>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
movl   $0x676e69,0x3(%rsp)
movl   $0x69727473,(%rsp)
lea    0xecd(%rip),%rdi
mov    %rsp,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    (%rsp),%al
test   %al,%al
je     1178 <main+0x58>
lea    0x1(%rsp),%rbx
lea    0xebe(%rip),%r14
nopw   0x0(%rax,%rax,1)
movsbl %al,%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
movzbl (%rbx),%eax
add    $0x1,%rbx
test   %al,%al
jne    1160 <main+0x40>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    (%rsp),%al
test   %al,%al
je     11b8 <main+0x98>
lea    0x1(%rsp),%rbx
lea    0xe80(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
nop
movsbl %al,%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
movzbl (%rbx),%eax
add    $0x1,%rbx
test   %al,%al
jne    11a0 <main+0x80>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@__const.main.s = [7 x i8] c"string\00"
@.str = [14 x i8] c"string is %s\0A\00"
@.str.1 = [13 x i8] c"char is: %c\0A\00"
@.str.2 = [2 x i8] c"\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [7 x i8]
%7 = alloca i32
%8 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = bitcast [7 x i8]* %6 to i8*
%10 = getelementptr inbounds [7 x i8], [7 x i8]* %6, i64 0, i64 0
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8* %10)
store i32 0, i32* %7
br label %12
12: ; preds = %26, %2
%13 = load i32, i32* %7
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds [7 x i8], [7 x i8]* %6, i64 0, i64 %14
%16 = load i8, i8* %15
%17 = sext i8 %16 to i32
%18 = icmp ne i32 %17, 0
br i1 %18, label %19, label %29
19: ; preds = %12
%20 = load i32, i32* %7
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds [7 x i8], [7 x i8]* %6, i64 0, i64 %21
%23 = load i8, i8* %22
%24 = sext i8 %23 to i32
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i32 %24)
br label %26
26: ; preds = %19
%27 = load i32, i32* %7
%28 = add nsw i32 %27, 1
store i32 %28, i32* %7
br label %12
29: ; preds = %12
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%31 = getelementptr inbounds [7 x i8], [7 x i8]* %6, i64 0, i64 0
store i8* %31, i8** %8
br label %32
32: ; preds = %41, %29
%33 = load i8*, i8** %8
%34 = load i8, i8* %33
%35 = icmp ne i8 %34, 0
br i1 %35, label %36, label %44
36: ; preds = %32
%37 = load i8*, i8** %8
%38 = load i8, i8* %37
%39 = sext i8 %38 to i32
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i32 %39)
br label %41
41: ; preds = %36
%42 = load i8*, i8** %8
%43 = getelementptr inbounds i8, i8* %42, i32 1
store i8* %43, i8** %8
br label %32
44: ; preds = %32
ret i32 0
}

LLVM IR (-O2):
@__const.main.s = [7 x i8] c"string\00"
@.str = [14 x i8] c"string is %s\0A\00"
@.str.1 = [13 x i8] c"char is: %c\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [7 x i8]
%4 = getelementptr inbounds [7 x i8], [7 x i8]* %3, i64 0, i64 0
%5 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8* %4)
%6 = load i8, i8* %4
%7 = icmp eq i8 %6, 0
br i1 %7, label %8, label %12
8: ; preds = %12, %2
%9 = call i32 @putchar(i32 10)
%10 = load i8, i8* %4
%11 = icmp eq i8 %10, 0
br i1 %11, label %21, label %22
12: ; preds = %2, %12
%13 = phi i64 [ %17, %12 ], [ 0, %2 ]
%14 = phi i8 [ %19, %12 ], [ %6, %2 ]
%15 = sext i8 %14 to i32
%16 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i32 %15)
%17 = add nuw i64 %13, 1
%18 = getelementptr inbounds [7 x i8], [7 x i8]* %3, i64 0, i64 %17
%19 = load i8, i8* %18
%20 = icmp eq i8 %19, 0
br i1 %20, label %8, label %12
21: ; preds = %22, %8
ret i32 0
22: ; preds = %8, %22
%23 = phi i8 [ %28, %22 ], [ %10, %8 ]
%24 = phi i8* [ %27, %22 ], [ %4, %8 ]
%25 = sext i8 %23 to i32
%26 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i32 %25)
%27 = getelementptr inbounds i8, i8* %24, i64 1
%28 = load i8, i8* %27
%29 = icmp eq i8 %28, 0
br i1 %29, label %21, label %22
}