#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*/ scanf(char *, char *);
int main() {
  char s1[100], s2[100];
  char i;
  printf("Enter string s1: ");
  scanf("%s", s1);
  for (i = 0; s1[i] != '\0'; ++i) {
    s2[i] = s1[i];
  }
  s2[i] = '\0';
  printf("\nCopy of String s1: %s\n", s2);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xf0,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xec7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x70(%rbp),%rsi
lea    0xec7(%rip),%rdi
call   1040 <scanf@plt>
movb   $0x0,-0xe1(%rbp)
movsbq -0xe1(%rbp),%rax
ff
movsbl -0x70(%rbp,%rax,1),%eax
cmp    $0x0,%eax
je     119b <main+0x7b>
movsbq -0xe1(%rbp),%rax
ff
mov    -0x70(%rbp,%rax,1),%cl
movsbq -0xe1(%rbp),%rax
ff
mov    %cl,-0xe0(%rbp,%rax,1)
mov    -0xe1(%rbp),%al
add    $0x1,%al
mov    %al,-0xe1(%rbp)
jmp    1157 <main+0x37>
movsbq -0xe1(%rbp),%rax
ff
movb   $0x0,-0xe0(%rbp,%rax,1)
lea    -0xe0(%rbp),%rsi
lea    0xe5c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0xf0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0xe0,%rsp
lea    0xed1(%rip),%rdi
xor    %ebx,%ebx
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xed3(%rip),%rdi
lea    0x70(%rsp),%rsi
call   1040 <scanf@plt>
mov    0x70(%rsp),%al
test   %al,%al
je     1173 <main+0x53>
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %al,(%rsp,%rbx,1)
add    $0x1,%bl
movsbq %bl,%rbx
movzbl 0x70(%rsp,%rbx,1),%eax
test   %al,%al
jne    1160 <main+0x40>
movb   $0x0,(%rsp,%rbx,1)
lea    0xe97(%rip),%rdi
mov    %rsp,%rsi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0xe0,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [18 x i8] c"Enter string s1: \00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [24 x i8] c"\0ACopy of String s1: %s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [100 x i8]
%3 = alloca [100 x i8]
%4 = alloca i8
store i32 0, i32* %1
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
%6 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %6)
store i8 0, i8* %4
br label %8
8: ; preds = %23, %0
%9 = load i8, i8* %4
%10 = sext i8 %9 to i64
%11 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 %10
%12 = load i8, i8* %11
%13 = sext i8 %12 to i32
%14 = icmp ne i32 %13, 0
br i1 %14, label %15, label %26
15: ; preds = %8
%16 = load i8, i8* %4
%17 = sext i8 %16 to i64
%18 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 %17
%19 = load i8, i8* %18
%20 = load i8, i8* %4
%21 = sext i8 %20 to i64
%22 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 %21
store i8 %19, i8* %22
br label %23
23: ; preds = %15
%24 = load i8, i8* %4
%25 = add i8 %24, 1
store i8 %25, i8* %4
br label %8
26: ; preds = %8
%27 = load i8, i8* %4
%28 = sext i8 %27 to i64
%29 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 %28
store i8 0, i8* %29
%30 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0), i8* %30)
ret i32 0
}

LLVM IR (-O2):
@.str = [18 x i8] c"Enter string s1: \00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [24 x i8] c"\0ACopy of String s1: %s\0A\00"
define i32 @main() {
%1 = alloca [100 x i8]
%2 = alloca [100 x i8]
%3 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%4 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %3)
%7 = load i8, i8* %3
%8 = icmp eq i8 %7, 0
br i1 %8, label %19, label %9
9: ; preds = %0, %9
%10 = phi i8 [ %17, %9 ], [ %7, %0 ]
%11 = phi i64 [ %15, %9 ], [ 0, %0 ]
%12 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 %11
store i8 %10, i8* %12
%13 = shl nsw i64 %11, 56
%14 = add i64 %13, 72057594037927936
%15 = ashr exact i64 %14, 56
%16 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 %15
%17 = load i8, i8* %16
%18 = icmp eq i8 %17, 0
br i1 %18, label %19, label %9
19: ; preds = %9, %0
%20 = phi i64 [ 0, %0 ], [ %15, %9 ]
%21 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 %20
store i8 0, i8* %21
%22 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0), i8* %4)
ret i32 0
}