#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*/ gets(char *);
int /*<<< orphan*/ printf(char *, ...);
int strlen(char *);
int main(void) {
  int len = 11;
  char str[10] = {0};
  printf("\n Enter the name \n");
  gets(str);
  printf("\n len = [%d] \n", len);
  len = strlen(str);
  printf("\n len of string entered is : [%d]\n", len);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0xb,-0x8(%rbp)
lea    -0x12(%rbp),%rdi
xor    %esi,%esi
mov    $0xa,%edx
call   1050 <memset@plt>
lea    0xe93(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x12(%rbp),%rdi
call   1060 <gets@plt>
mov    -0x8(%rbp),%esi
lea    0xe8c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x12(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%esi
lea    0xe7e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
movw   $0x0,0x8(%rsp)
movq   $0x0,(%rsp)
lea    0xed7(%rip),%rdi
call   1030 <puts@plt>
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1060 <gets@plt>
lea    0xe8e(%rip),%rdi
mov    $0xb,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
call   1040 <strlen@plt>
lea    0xe82(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [19 x i8] c"\0A Enter the name \0A\00"
@.str.1 = [15 x i8] c"\0A len = [%d] \0A\00"
@.str.2 = [35 x i8] c"\0A len of string entered is : [%d]\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [10 x i8]
store i32 0, i32* %1
store i32 11, i32* %2
%4 = bitcast [10 x i8]* %3 to i8*
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
%6 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 0
%7 = call i32 @gets(i8* %6)
%8 = load i32, i32* %2
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i32 %8)
%10 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 0
%11 = call i32 @strlen(i8* %10)
store i32 %11, i32* %2
%12 = load i32, i32* %2
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.2, i64 0, i64 0), i32 %12)
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [15 x i8] c"\0A len = [%d] \0A\00"
@.str.2 = [35 x i8] c"\0A len of string entered is : [%d]\0A\00"
@str = [18 x i8] c"\0A Enter the name \00"
define i32 @main() {
%1 = alloca [10 x i8]
%2 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 0
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str, i64 0, i64 0))
%4 = call i32 @gets(i8* %2)
%5 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i32 11)
%6 = call i32 @strlen(i8* %2)
%7 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str.2, i64 0, i64 0), i32 %6)
ret i32 0
}