#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 */
typedef int /*<<< orphan*/ buff;

/* Variables and functions */
int atoi(char *);
char *fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
scalar_t__ scanf(char *, float *);
int /*<<< orphan*/ stdin;
int main(int argc, char **argv) {
  printf("convert millimeter to pixel.\n");
  int ppi;
  while (1) {
    printf("ppi> (default 72) ");
    char buff[8];
    char *s = fgets(buff, sizeof(buff), stdin);
    if (s[0] == '\n') {
      ppi = 72;
      break;
    }
    ppi = atoi(s);
    if (ppi <= 0) {
      printf("input error. please re-input.\n");
      continue;
    }
    break;
  }
  printf("set ppi to %d\n", ppi);
  float val;
  while (1) {
    printf("mm> ");
    if (scanf("%f", &val) == 0) {
      continue;
    }
    printf("%d\n", (int)(val / 2.54f * ppi));
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xea7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeb7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x1c(%rbp),%rdi
mov    0x2e6b(%rip),%rax
mov    (%rax),%edx
mov    $0x8,%esi
call   1040 <fgets@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
movsbl (%rax),%eax
cmp    $0xa,%eax
jne    11a9 <main+0x69>
movl   $0x48,-0x14(%rbp)
jmp    11d7 <main+0x97>
mov    -0x28(%rbp),%rdi
call   1060 <atoi@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jg     11d2 <main+0x92>
lea    0xe6f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1164 <main+0x24>
jmp    11d7 <main+0x97>
mov    -0x14(%rbp),%esi
lea    0xe73(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe74(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe6b(%rip),%rdi
lea    -0x2c(%rbp),%rsi
call   1050 <scanf@plt>
cmp    $0x0,%rax
jne    1215 <main+0xd5>
jmp    11e8 <main+0xa8>
movss  -0x2c(%rbp),%xmm0
movss  0xdde(%rip),%xmm1
divss  %xmm1,%xmm0
cvtsi2ssl -0x14(%rbp),%xmm1
mulss  %xmm1,%xmm0
cvttss2si %xmm0,%esi
lea    0xe25(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11e8 <main+0xa8>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
lea    0xecb(%rip),%rdi
call   1030 <puts@plt>
lea    0xe95(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x2e6b(%rip),%r12
mov    (%r12),%edx
lea    0x8(%rsp),%rdi
mov    $0x8,%esi
call   1050 <fgets@plt>
mov    $0x48,%r14d
cmpb   $0xa,(%rax)
je     11e9 <main+0x99>
lea    0xea9(%rip),%r15
lea    0xe5b(%rip),%rbp
lea    0x8(%rsp),%rbx
xchg   %ax,%ax
mov    %rax,%rdi
call   1070 <atoi@plt>
test   %eax,%eax
jg     11e6 <main+0x96>
mov    %r15,%rdi
call   1030 <puts@plt>
mov    %rbp,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    (%r12),%edx
mov    %rbx,%rdi
mov    $0x8,%esi
call   1050 <fgets@plt>
cmpb   $0xa,(%rax)
jne    11b0 <main+0x60>
jmp    11e9 <main+0x99>
mov    %eax,%r14d
lea    0xe27(%rip),%rdi
mov    %r14d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
cvtsi2ss %r14d,%xmm0
movss  %xmm0,(%rsp)
lea    0xe1b(%rip),%r14
lea    0xe19(%rip),%rbp
lea    0x4(%rsp),%rbx
lea    0xe04(%rip),%r15
xchg   %ax,%ax
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbp,%rdi
mov    %rbx,%rsi
call   1060 <scanf@plt>
test   %rax,%rax
je     1220 <main+0xd0>
movss  0x4(%rsp),%xmm0
divss  0xdb8(%rip),%xmm0
mulss  (%rsp),%xmm0
cvttss2si %xmm0,%esi
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    1220 <main+0xd0>

LLVM IR (-O0):
@.str = [30 x i8] c"convert millimeter to pixel.\0A\00"
@.str.1 = [19 x i8] c"ppi> (default 72) \00"
@stdin = global i32 0
@.str.2 = [31 x i8] c"input error. please re-input.\0A\00"
@.str.3 = [15 x i8] c"set ppi to %d\0A\00"
@.str.4 = [5 x i8] c"mm> \00"
@.str.5 = [3 x i8] c"%f\00"
@.str.6 = [4 x i8] c"%d\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca [8 x i8]
%8 = alloca i8*
%9 = alloca float
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0))
br label %11
11: ; preds = %2, %27
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0))
%13 = getelementptr inbounds [8 x i8], [8 x i8]* %7, i64 0, i64 0
%14 = load i32, i32* @stdin
%15 = call i8* @fgets(i8* %13, i32 8, i32 %14)
store i8* %15, i8** %8
%16 = load i8*, i8** %8
%17 = getelementptr inbounds i8, i8* %16, i64 0
%18 = load i8, i8* %17
%19 = sext i8 %18 to i32
%20 = icmp eq i32 %19, 10
br i1 %20, label %21, label %22
21: ; preds = %11
store i32 72, i32* %6
br label %30
22: ; preds = %11
%23 = load i8*, i8** %8
%24 = call i32 @atoi(i8* %23)
store i32 %24, i32* %6
%25 = load i32, i32* %6
%26 = icmp sle i32 %25, 0
br i1 %26, label %27, label %29
27: ; preds = %22
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0))
br label %11
29: ; preds = %22
br label %30
30: ; preds = %29, %21
%31 = load i32, i32* %6
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0), i32 %31)
br label %33
33: ; preds = %30, %37, %38
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
%35 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), float* %9)
%36 = icmp eq i64 %35, 0
br i1 %36, label %37, label %38
37: ; preds = %33
br label %33
38: ; preds = %33
%39 = load float, float* %9
%40 = fdiv float %39, 0x400451EB80000000
%41 = load i32, i32* %6
%42 = sitofp i32 %41 to float
%43 = fmul float %40, %42
%44 = fptosi float %43 to i32
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i32 %44)
br label %33
}

LLVM IR (-O2):
@.str.1 = [19 x i8] c"ppi> (default 72) \00"
@stdin = global i32 0
@.str.3 = [15 x i8] c"set ppi to %d\0A\00"
@.str.4 = [5 x i8] c"mm> \00"
@.str.5 = [3 x i8] c"%f\00"
@.str.6 = [4 x i8] c"%d\0A\00"
@str = [29 x i8] c"convert millimeter to pixel.\00"
@str.7 = [30 x i8] c"input error. please re-input.\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [8 x i8]
%4 = alloca float
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @str, i64 0, i64 0))
%6 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0))
%7 = getelementptr inbounds [8 x i8], [8 x i8]* %3, i64 0, i64 0
%8 = load i32, i32* @stdin
%9 = call i8* @fgets(i8* %7, i32 8, i32 %8)
%10 = load i8, i8* %9
%11 = icmp eq i8 %10, 10
br i1 %11, label %23, label %12
12: ; preds = %2, %16
%13 = phi i8* [ %20, %16 ], [ %9, %2 ]
%14 = call i32 @atoi(i8* %13)
%15 = icmp slt i32 %14, 1
br i1 %15, label %16, label %23
16: ; preds = %12
%17 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @str.7, i64 0, i64 0))
%18 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0))
%19 = load i32, i32* @stdin
%20 = call i8* @fgets(i8* %7, i32 8, i32 %19)
%21 = load i8, i8* %20
%22 = icmp eq i8 %21, 10
br i1 %22, label %23, label %12
23: ; preds = %12, %16, %2
%24 = phi i32 [ 72, %2 ], [ 72, %16 ], [ %14, %12 ]
%25 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0), i32 %24)
%26 = bitcast float* %4 to i8*
%27 = sitofp i32 %24 to float
br label %28
28: ; preds = %38, %23
%29 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
%30 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), float* %4)
%31 = icmp eq i64 %30, 0
br i1 %31, label %38, label %32
32: ; preds = %28
%33 = load float, float* %4
%34 = fdiv float %33, 0x400451EB80000000
%35 = fmul float %34, %27
%36 = fptosi float %35 to i32
%37 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i32 %36)
br label %38
38: ; preds = %32, %28
br label %28
}