#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(int argc, const char *argv[]) {
  char name1[256];
  char name2[256];
  int nameLength1 = 0, nameLength2 = 0;
  printf("===== Exercise 11 =====\n");
  printf("Get the size of each two names!\n");
  printf("*You cannot have spaces.\n");
  printf("Enter the Name1.: ");
  scanf("%s", name1);
  for (int i = 0; name1[i] != '\0'; i++) {
    nameLength1++;
  }
  printf("Enter the Name2.: ");
  scanf("%s", name2);
  for (int j = 0; name2[j] != '\0'; j++) {
    nameLength2++;
  }
  printf("--> The size of Name1 is %i.\n", nameLength1);
  printf("--> The size of Name2 is %i.\n", nameLength2);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x220,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x214(%rbp)
movl   $0x0,-0x218(%rbp)
lea    0xeac(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeb7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeca(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xed6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x110(%rbp),%rsi
lea    0xed4(%rip),%rdi
call   1040 <scanf@plt>
movl   $0x0,-0x21c(%rbp)
movslq -0x21c(%rbp),%rax
movsbl -0x110(%rbp,%rax,1),%eax
ff
cmp    $0x0,%eax
je     11dd <main+0xbd>
mov    -0x214(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x214(%rbp)
mov    -0x21c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x21c(%rbp)
jmp    11a2 <main+0x82>
lea    0xe86(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x210(%rbp),%rsi
lea    0xe6e(%rip),%rdi
call   1040 <scanf@plt>
movl   $0x0,-0x220(%rbp)
movslq -0x220(%rbp),%rax
movsbl -0x210(%rbp,%rax,1),%eax
ff
cmp    $0x0,%eax
je     1243 <main+0x123>
mov    -0x218(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x218(%rbp)
mov    -0x220(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x220(%rbp)
jmp    1208 <main+0xe8>
mov    -0x214(%rbp),%esi
lea    0xe2d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x218(%rbp),%esi
lea    0xe37(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x220,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x208,%rsp
lea    0xf24(%rip),%rdi
call   1030 <puts@plt>
lea    0xf30(%rip),%rdi
call   1030 <puts@plt>
lea    0xf44(%rip),%rdi
call   1030 <puts@plt>
lea    0xe9b(%rip),%rdi
xor    %r14d,%r14d
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe9d(%rip),%rdi
lea    0x100(%rsp),%rsi
call   1050 <scanf@plt>
cmpb   $0x0,0x100(%rsp)
mov    $0x0,%ebx
je     11ae <main+0x7e>
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
cmpb   $0x0,0x101(%rsp,%rbx,1)
lea    0x1(%rbx),%rbx
jne    11a0 <main+0x70>
lea    0xe61(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe50(%rip),%rdi
mov    %rsp,%rsi
call   1050 <scanf@plt>
cmpb   $0x0,(%rsp)
je     11ec <main+0xbc>
xor    %r14d,%r14d
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
cmpb   $0x0,0x1(%rsp,%r14,1)
lea    0x1(%r14),%r14
jne    11e0 <main+0xb0>
lea    0xe36(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe44(%rip),%rdi
mov    %r14d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x208,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [25 x i8] c"===== Exercise 11 =====\0A\00"
@.str.1 = [33 x i8] c"Get the size of each two names!\0A\00"
@.str.2 = [26 x i8] c"*You cannot have spaces.\0A\00"
@.str.3 = [19 x i8] c"Enter the Name1.: \00"
@.str.4 = [3 x i8] c"%s\00"
@.str.5 = [19 x i8] c"Enter the Name2.: \00"
@.str.6 = [30 x i8] c"--> The size of Name1 is %i.\0A\00"
@.str.7 = [30 x i8] c"--> The size of Name2 is %i.\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [256 x i8]
%7 = alloca [256 x i8]
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %8
store i32 0, i32* %9
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0))
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0))
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0))
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0))
%16 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%17 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %16)
store i32 0, i32* %10
br label %18
18: ; preds = %28, %2
%19 = load i32, i32* %10
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 %20
%22 = load i8, i8* %21
%23 = sext i8 %22 to i32
%24 = icmp ne i32 %23, 0
br i1 %24, label %25, label %31
25: ; preds = %18
%26 = load i32, i32* %8
%27 = add nsw i32 %26, 1
store i32 %27, i32* %8
br label %28
28: ; preds = %25
%29 = load i32, i32* %10
%30 = add nsw i32 %29, 1
store i32 %30, i32* %10
br label %18
31: ; preds = %18
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.5, i64 0, i64 0))
%33 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 0
%34 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %33)
store i32 0, i32* %11
br label %35
35: ; preds = %45, %31
%36 = load i32, i32* %11
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 %37
%39 = load i8, i8* %38
%40 = sext i8 %39 to i32
%41 = icmp ne i32 %40, 0
br i1 %41, label %42, label %48
42: ; preds = %35
%43 = load i32, i32* %9
%44 = add nsw i32 %43, 1
store i32 %44, i32* %9
br label %45
45: ; preds = %42
%46 = load i32, i32* %11
%47 = add nsw i32 %46, 1
store i32 %47, i32* %11
br label %35
48: ; preds = %35
%49 = load i32, i32* %8
%50 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.6, i64 0, i64 0), i32 %49)
%51 = load i32, i32* %9
%52 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.7, i64 0, i64 0), i32 %51)
ret i32 0
}

LLVM IR (-O2):
@.str.3 = [19 x i8] c"Enter the Name1.: \00"
@.str.4 = [3 x i8] c"%s\00"
@.str.5 = [19 x i8] c"Enter the Name2.: \00"
@.str.6 = [30 x i8] c"--> The size of Name1 is %i.\0A\00"
@.str.7 = [30 x i8] c"--> The size of Name2 is %i.\0A\00"
@str = [24 x i8] c"===== Exercise 11 =====\00"
@str.8 = [32 x i8] c"Get the size of each two names!\00"
@str.9 = [25 x i8] c"*You cannot have spaces.\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [256 x i8]
%4 = alloca [256 x i8]
%5 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%6 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 0
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @str, i64 0, i64 0))
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @str.8, i64 0, i64 0))
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str.9, i64 0, i64 0))
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0))
%11 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %5)
%12 = load i8, i8* %5
%13 = icmp eq i8 %12, 0
br i1 %13, label %16, label %22
14: ; preds = %22
%15 = trunc i64 %24 to i32
br label %16
16: ; preds = %14, %2
%17 = phi i32 [ 0, %2 ], [ %15, %14 ]
%18 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.5, i64 0, i64 0))
%19 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %6)
%20 = load i8, i8* %6
%21 = icmp eq i8 %20, 0
br i1 %21, label %30, label %34
22: ; preds = %2, %22
%23 = phi i64 [ %24, %22 ], [ 0, %2 ]
%24 = add nuw nsw i64 %23, 1
%25 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 %24
%26 = load i8, i8* %25
%27 = icmp eq i8 %26, 0
br i1 %27, label %14, label %22
28: ; preds = %34
%29 = trunc i64 %36 to i32
br label %30
30: ; preds = %28, %16
%31 = phi i32 [ 0, %16 ], [ %29, %28 ]
%32 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.6, i64 0, i64 0), i32 %17)
%33 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.7, i64 0, i64 0), i32 %31)
ret i32 0
34: ; preds = %16, %34
%35 = phi i64 [ %36, %34 ], [ 0, %16 ]
%36 = add nuw nsw i64 %35, 1
%37 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 %36
%38 = load i8, i8* %37
%39 = icmp eq i8 %38, 0
br i1 %39, label %28, label %34
}