#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 *, int *);
int main() {
  int x;
  printf("please input a number:\n");
  scanf("%d", &x);
  if (x <= 1)
    printf("y=1");
  else {
    if (x < 10)
      printf("y=%d\n", x);
    else {
      printf("y=2*x+1\n =2*%d+1\n =%d\n", x, 2 * x + 1);
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xed4(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
cmpl   $0x1,-0x8(%rbp)
jg     116a <main+0x4a>
lea    0xebd(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11a9 <main+0x89>
cmpl   $0xa,-0x8(%rbp)
jge    118a <main+0x6a>
mov    -0x8(%rbp),%esi
lea    0xea1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11a4 <main+0x84>
mov    -0x8(%rbp),%esi
mov    -0x8(%rbp),%edx
shl    $0x1,%edx
add    $0x1,%edx
lea    0xe88(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11a9 <main+0x89>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xeec(%rip),%rdi
call   1030 <puts@plt>
lea    0xebc(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1050 <scanf@plt>
mov    0x4(%rsp),%esi
cmp    $0x1,%esi
jg     1167 <main+0x37>
lea    0xea5(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    1190 <main+0x60>
cmp    $0x9,%esi
ja     117c <main+0x4c>
lea    0xe94(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    1190 <main+0x60>
lea    (%rsi,%rsi,1),%edx
add    $0x1,%edx
lea    0xe84(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [24 x i8] c"please input a number:\0A\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [4 x i8] c"y=1\00"
@.str.3 = [6 x i8] c"y=%d\0A\00"
@.str.4 = [23 x i8] c"y=2*x+1\0A =2*%d+1\0A =%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
store i32 0, i32* %1
%3 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%5 = load i32, i32* %2
%6 = icmp sle i32 %5, 1
br i1 %6, label %7, label %9
7: ; preds = %0
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
br label %22
9: ; preds = %0
%10 = load i32, i32* %2
%11 = icmp slt i32 %10, 10
br i1 %11, label %12, label %15
12: ; preds = %9
%13 = load i32, i32* %2
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i32 %13)
br label %21
15: ; preds = %9
%16 = load i32, i32* %2
%17 = load i32, i32* %2
%18 = mul nsw i32 2, %17
%19 = add nsw i32 %18, 1
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0), i32 %16, i32 %19)
br label %21
21: ; preds = %15, %12
br label %22
22: ; preds = %21, %7
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [4 x i8] c"y=1\00"
@.str.3 = [6 x i8] c"y=%d\0A\00"
@.str.4 = [23 x i8] c"y=2*x+1\0A =2*%d+1\0A =%d\0A\00"
@str = [23 x i8] c"please input a number:\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str, i64 0, i64 0))
%4 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%5 = load i32, i32* %1
%6 = icmp slt i32 %5, 2
br i1 %6, label %7, label %9
7: ; preds = %0
%8 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
br label %17
9: ; preds = %0
%10 = icmp ult i32 %5, 10
br i1 %10, label %11, label %13
11: ; preds = %9
%12 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i32 %5)
br label %17
13: ; preds = %9
%14 = shl nuw nsw i32 %5, 1
%15 = or i32 %14, 1
%16 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0), i32 %5, i32 %15)
br label %17
17: ; preds = %11, %13, %7
ret i32 0
}