#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 *, char);
char puts(char *);
main() {
  char ch, c[12] = "hello";
  char ch2[12];
  int i;
  for (i = 0; i < 4; i++) {
    ch2[i] = c[i];
  }
  printf("\n%c", ch2[3]);
  ch = puts("manish");
  printf("\n%d", ch);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xeca(%rip),%rax
mov    %rax,-0x11(%rbp)
mov    0xec8(%rip),%eax
mov    %eax,-0x9(%rbp)
movl   $0x0,-0x24(%rbp)
cmpl   $0x4,-0x24(%rbp)
jge    1172 <main+0x52>
movslq -0x24(%rbp),%rax
mov    -0x11(%rbp,%rax,1),%cl
movslq -0x24(%rbp),%rax
mov    %cl,-0x1d(%rbp,%rax,1)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    114a <main+0x2a>
lea    0xe93(%rip),%rdi
movsbl -0x1a(%rbp),%esi
call   1040 <printf@plt>
lea    0xe87(%rip),%rdi
call   1030 <puts@plt>
mov    %al,-0x5(%rbp)
lea    0xe7f(%rip),%rdi
movsbl -0x5(%rbp),%esi
call   1040 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xed8(%rip),%rdi
mov    $0x6c,%esi
call   1040 <printf@plt>
lea    0xecb(%rip),%rdi
call   1030 <puts@plt>
movsbl %al,%esi
lea    0xec3(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@__const.main.c = [12 x i8] c"hello\00\00\00\00\00\00\00"
@.str = [4 x i8] c"\0A%c\00"
@.str.1 = [7 x i8] c"manish\00"
@.str.2 = [4 x i8] c"\0A%d\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8
%3 = alloca [12 x i8]
%4 = alloca [12 x i8]
%5 = alloca i32
store i32 0, i32* %1
%6 = bitcast [12 x i8]* %3 to i8*
store i32 0, i32* %5
br label %7
7: ; preds = %18, %0
%8 = load i32, i32* %5
%9 = icmp slt i32 %8, 4
br i1 %9, label %10, label %21
10: ; preds = %7
%11 = load i32, i32* %5
%12 = sext i32 %11 to i64
%13 = getelementptr inbounds [12 x i8], [12 x i8]* %3, i64 0, i64 %12
%14 = load i8, i8* %13
%15 = load i32, i32* %5
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds [12 x i8], [12 x i8]* %4, i64 0, i64 %16
store i8 %14, i8* %17
br label %18
18: ; preds = %10
%19 = load i32, i32* %5
%20 = add nsw i32 %19, 1
store i32 %20, i32* %5
br label %7
21: ; preds = %7
%22 = getelementptr inbounds [12 x i8], [12 x i8]* %4, i64 0, i64 3
%23 = load i8, i8* %22
%24 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8 signext %23)
%25 = call signext i8 @puts(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
store i8 %25, i8* %2
%26 = load i8, i8* %2
%27 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8 signext %26)
%28 = load i32, i32* %1
ret i32 %28
}

LLVM IR (-O2):
@.str = [4 x i8] c"\0A%c\00"
@.str.1 = [7 x i8] c"manish\00"
@.str.2 = [4 x i8] c"\0A%d\00"
define i32 @main() {
%1 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8 signext 108)
%2 = tail call signext i8 @puts(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%3 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8 signext %2)
ret i32 0
}