#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 str_loc(char *, char *);
int main() {
  char str[50], s1[50], s2[50];
  scanf("%s", str);
  scanf("%s", s1);
  scanf("%s", s2);
  int n = str_loc(str, s1);
  char s3[50];
  int i = 0;
  for (; i < n; i++) {
    s3[i] = str[i];
    printf("loop iteration %d\n", i);
  }
  s3[i] = '\0';
  printf("%s%s", s3, s2);
  while (str[i] != '\0') {
    printf("%c", str[i]);
    i++;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x110,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x40(%rbp),%rsi
lea    0xec8(%rip),%rdi
call   1050 <scanf@plt>
lea    -0x80(%rbp),%rsi
lea    0xeb8(%rip),%rdi
call   1050 <scanf@plt>
lea    -0xc0(%rbp),%rsi
lea    0xea5(%rip),%rdi
call   1050 <scanf@plt>
lea    -0x40(%rbp),%rdi
lea    -0x80(%rbp),%rsi
call   1040 <str_loc@plt>
mov    %eax,-0xc4(%rbp)
movl   $0x0,-0x104(%rbp)
mov    -0x104(%rbp),%eax
cmp    -0xc4(%rbp),%eax
jge    11e5 <main+0xb5>
movslq -0x104(%rbp),%rax
mov    -0x40(%rbp,%rax,1),%cl
movslq -0x104(%rbp),%rax
mov    %cl,-0x100(%rbp,%rax,1)
mov    -0x104(%rbp),%esi
lea    0xe36(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x104(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x104(%rbp)
jmp    1192 <main+0x62>
movslq -0x104(%rbp),%rax
movb   $0x0,-0x100(%rbp,%rax,1)
lea    -0x100(%rbp),%rsi
lea    -0xc0(%rbp),%rdx
lea    0xe0a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movslq -0x104(%rbp),%rax
movsbl -0x40(%rbp,%rax,1),%eax
cmp    $0x0,%eax
je     1253 <main+0x123>
movslq -0x104(%rbp),%rax
movsbl -0x40(%rbp,%rax,1),%esi
lea    0xde0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x104(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x104(%rbp)
jmp    1210 <main+0xe0>
xor    %eax,%eax
add    $0x110,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0xf8,%rsp
lea    0xec0(%rip),%rbx
lea    0x40(%rsp),%r14
mov    %rbx,%rdi
mov    %r14,%rsi
call   1060 <scanf@plt>
lea    0xc0(%rsp),%r15
mov    %rbx,%rdi
mov    %r15,%rsi
call   1060 <scanf@plt>
lea    0x80(%rsp),%rsi
mov    %rbx,%rdi
call   1060 <scanf@plt>
mov    %r14,%rdi
mov    %r15,%rsi
call   1050 <str_loc@plt>
test   %eax,%eax
jle    11cf <main+0x8f>
mov    %eax,%r12d
lea    0xe5f(%rip),%r15
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movzbl 0x40(%rsp,%rbx,1),%eax
mov    %al,(%rsp,%rbx,1)
mov    %r15,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%rbx
cmp    %rbx,%r12
jne    11b0 <main+0x70>
jmp    11d2 <main+0x92>
xor    %r12d,%r12d
movb   $0x0,(%rsp,%r12,1)
lea    0xe35(%rip),%rdi
mov    %rsp,%rsi
lea    0x80(%rsp),%rdx
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x40(%rsp,%r12,1),%al
test   %al,%al
je     1223 <main+0xe3>
lea    (%r12,%r14,1),%rbx
add    $0x1,%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movsbl %al,%edi
call   1030 <putchar@plt>
movzbl (%rbx),%eax
add    $0x1,%rbx
test   %al,%al
jne    1210 <main+0xd0>
xor    %eax,%eax
add    $0xf8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%s\00"
@.str.1 = [19 x i8] c"loop iteration %d\0A\00"
@.str.2 = [5 x i8] c"%s%s\00"
@.str.3 = [3 x i8] c"%c\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [50 x i8]
%3 = alloca [50 x i8]
%4 = alloca [50 x i8]
%5 = alloca i32
%6 = alloca [50 x i8]
%7 = alloca i32
store i32 0, i32* %1
%8 = getelementptr inbounds [50 x i8], [50 x i8]* %2, i64 0, i64 0
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %8)
%10 = getelementptr inbounds [50 x i8], [50 x i8]* %3, i64 0, i64 0
%11 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %10)
%12 = getelementptr inbounds [50 x i8], [50 x i8]* %4, i64 0, i64 0
%13 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %12)
%14 = getelementptr inbounds [50 x i8], [50 x i8]* %2, i64 0, i64 0
%15 = getelementptr inbounds [50 x i8], [50 x i8]* %3, i64 0, i64 0
%16 = call i32 @str_loc(i8* %14, i8* %15)
store i32 %16, i32* %5
store i32 0, i32* %7
br label %17
17: ; preds = %31, %0
%18 = load i32, i32* %7
%19 = load i32, i32* %5
%20 = icmp slt i32 %18, %19
br i1 %20, label %21, label %34
21: ; preds = %17
%22 = load i32, i32* %7
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds [50 x i8], [50 x i8]* %2, i64 0, i64 %23
%25 = load i8, i8* %24
%26 = load i32, i32* %7
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds [50 x i8], [50 x i8]* %6, i64 0, i64 %27
store i8 %25, i8* %28
%29 = load i32, i32* %7
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i32 %29)
br label %31
31: ; preds = %21
%32 = load i32, i32* %7
%33 = add nsw i32 %32, 1
store i32 %33, i32* %7
br label %17
34: ; preds = %17
%35 = load i32, i32* %7
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds [50 x i8], [50 x i8]* %6, i64 0, i64 %36
store i8 0, i8* %37
%38 = getelementptr inbounds [50 x i8], [50 x i8]* %6, i64 0, i64 0
%39 = getelementptr inbounds [50 x i8], [50 x i8]* %4, i64 0, i64 0
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* %38, i8* %39)
br label %41
41: ; preds = %48, %34
%42 = load i32, i32* %7
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds [50 x i8], [50 x i8]* %2, i64 0, i64 %43
%45 = load i8, i8* %44
%46 = sext i8 %45 to i32
%47 = icmp ne i32 %46, 0
br i1 %47, label %48, label %57
48: ; preds = %41
%49 = load i32, i32* %7
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds [50 x i8], [50 x i8]* %2, i64 0, i64 %50
%52 = load i8, i8* %51
%53 = sext i8 %52 to i32
%54 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32 %53)
%55 = load i32, i32* %7
%56 = add nsw i32 %55, 1
store i32 %56, i32* %7
br label %41
57: ; preds = %41
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"%s\00"
@.str.1 = [19 x i8] c"loop iteration %d\0A\00"
@.str.2 = [5 x i8] c"%s%s\00"
define i32 @main() {
%1 = alloca [50 x i8]
%2 = alloca [50 x i8]
%3 = alloca [50 x i8]
%4 = alloca [50 x i8]
%5 = getelementptr inbounds [50 x i8], [50 x i8]* %1, i64 0, i64 0
%6 = getelementptr inbounds [50 x i8], [50 x i8]* %2, i64 0, i64 0
%7 = getelementptr inbounds [50 x i8], [50 x i8]* %3, i64 0, i64 0
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %5)
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %6)
%10 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %7)
%11 = call i32 @str_loc(i8* %5, i8* %6)
%12 = getelementptr inbounds [50 x i8], [50 x i8]* %4, i64 0, i64 0
%13 = icmp sgt i32 %11, 0
br i1 %13, label %14, label %27
14: ; preds = %0
%15 = zext i32 %11 to i64
br label %16
16: ; preds = %14, %16
%17 = phi i64 [ 0, %14 ], [ %23, %16 ]
%18 = getelementptr inbounds [50 x i8], [50 x i8]* %1, i64 0, i64 %17
%19 = load i8, i8* %18
%20 = getelementptr inbounds [50 x i8], [50 x i8]* %4, i64 0, i64 %17
store i8 %19, i8* %20
%21 = trunc i64 %17 to i32
%22 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i32 %21)
%23 = add nuw nsw i64 %17, 1
%24 = icmp eq i64 %23, %15
br i1 %24, label %25, label %16
25: ; preds = %16
%26 = zext i32 %11 to i64
br label %27
27: ; preds = %0, %25
%28 = phi i64 [ %26, %25 ], [ 0, %0 ]
%29 = getelementptr inbounds [50 x i8], [50 x i8]* %4, i64 0, i64 %28
store i8 0, i8* %29
%30 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* %12, i8* %7)
%31 = getelementptr inbounds [50 x i8], [50 x i8]* %1, i64 0, i64 %28
%32 = load i8, i8* %31
%33 = icmp eq i8 %32, 0
br i1 %33, label %43, label %34
34: ; preds = %27, %34
%35 = phi i64 [ %39, %34 ], [ %28, %27 ]
%36 = phi i8 [ %41, %34 ], [ %32, %27 ]
%37 = sext i8 %36 to i32
%38 = call i32 @putchar(i32 %37)
%39 = add nuw i64 %35, 1
%40 = getelementptr inbounds [50 x i8], [50 x i8]* %1, i64 0, i64 %39
%41 = load i8, i8* %40
%42 = icmp eq i8 %41, 0
br i1 %42, label %43, label %34
43: ; preds = %34, %27
ret i32 0
}