#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);
int /*<<< orphan*/ puts(char *);
main() {
  char str[20];
  int v = 0, i, k;
  puts("Enter string");
  gets(str);
  for (i = 0; str[i]; i++) {
    if (str[i] == '.')
      break;
    else
      v = v * 10 + str[i] - 48;
  }
  printf("%d\n", v);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x24(%rbp)
lea    0xeb3(%rip),%rdi
call   1030 <puts@plt>
lea    -0x20(%rbp),%rdi
call   1050 <gets@plt>
movl   $0x0,-0x28(%rbp)
movslq -0x28(%rbp),%rax
cmpb   $0x0,-0x20(%rbp,%rax,1)
je     11b0 <main+0x80>
movslq -0x28(%rbp),%rax
movsbl -0x20(%rbp,%rax,1),%eax
cmp    $0x2e,%eax
jne    1188 <main+0x58>
jmp    11b0 <main+0x80>
imul   $0xa,-0x24(%rbp),%eax
movslq -0x28(%rbp),%rcx
movsbl -0x20(%rbp,%rcx,1),%ecx
add    %ecx,%eax
sub    $0x30,%eax
mov    %eax,-0x24(%rbp)
jmp    11a2 <main+0x72>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    1162 <main+0x32>
mov    -0x24(%rbp),%esi
lea    0xe53(%rip),%rdi
call   1040 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x20,%rsp
lea    0xec4(%rip),%rdi
call   1030 <puts@plt>
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1050 <gets@plt>
xor    %esi,%esi
xchg   %ax,%ax
movsbl (%rbx),%eax
test   %eax,%eax
je     116a <main+0x3a>
cmp    $0x2e,%al
je     116a <main+0x3a>
lea    (%rsi,%rsi,4),%ecx
lea    (%rax,%rcx,2),%esi
add    $0xffffffd0,%esi
add    $0x1,%rbx
jmp    1150 <main+0x20>
lea    0xe9c(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [13 x i8] c"Enter string\00"
@.str.1 = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [20 x i8]
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %3
%6 = call i32 @puts(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%7 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 0
%8 = call i32 @gets(i8* %7)
store i32 0, i32* %4
br label %9
9: ; preds = %34, %0
%10 = load i32, i32* %4
%11 = sext i32 %10 to i64
%12 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 %11
%13 = load i8, i8* %12
%14 = icmp ne i8 %13, 0
br i1 %14, label %15, label %37
15: ; preds = %9
%16 = load i32, i32* %4
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 %17
%19 = load i8, i8* %18
%20 = sext i8 %19 to i32
%21 = icmp eq i32 %20, 46
br i1 %21, label %22, label %23
22: ; preds = %15
br label %37
23: ; preds = %15
%24 = load i32, i32* %3
%25 = mul nsw i32 %24, 10
%26 = load i32, i32* %4
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 %27
%29 = load i8, i8* %28
%30 = sext i8 %29 to i32
%31 = add nsw i32 %25, %30
%32 = sub nsw i32 %31, 48
store i32 %32, i32* %3
br label %33
33: ; preds = %23
br label %34
34: ; preds = %33
%35 = load i32, i32* %4
%36 = add nsw i32 %35, 1
store i32 %36, i32* %4
br label %9
37: ; preds = %22, %9
%38 = load i32, i32* %3
%39 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %38)
%40 = load i32, i32* %1
ret i32 %40
}

LLVM IR (-O2):
@.str = [13 x i8] c"Enter string\00"
@.str.1 = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca [20 x i8]
%2 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 0
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @gets(i8* %2)
br label %5
5: ; preds = %10, %0
%6 = phi i64 [ %15, %10 ], [ 0, %0 ]
%7 = phi i32 [ %14, %10 ], [ 0, %0 ]
%8 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 %6
%9 = load i8, i8* %8
switch i8 %9, label %10 [
i8 0, label %16
i8 46, label %16
]
10: ; preds = %5
%11 = sext i8 %9 to i32
%12 = mul nsw i32 %7, 10
%13 = add i32 %12, -48
%14 = add i32 %13, %11
%15 = add nuw i64 %6, 1
br label %5
16: ; preds = %5, %5
%17 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %7)
ret i32 0
}