#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);
int get_smallest_number(int max_num) {
  printf("start with max_num == %i ... ", max_num);
  int smallest_number = 1;
  int is_evenly_divisible = 1;
  while (1) {
    int i;
    for (i = 1; i <= max_num; i++) {
      if (smallest_number % i != 0) {
        is_evenly_divisible = 0;
        break;
      }
      is_evenly_divisible = 1;
    }
    if (is_evenly_divisible) {
      return smallest_number;
    }
    smallest_number += 1;
  }
}


x86 assembly (clang, -O0):
<get_smallest_number>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%esi
lea    0xedb(%rip),%rdi
call   1030 <printf@plt>
movl   $0x1,-0x8(%rbp)
movl   $0x1,-0xc(%rbp)
movl   $0x1,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0x4(%rbp),%eax
jg     117c <get_smallest_number+0x6c>
mov    -0x8(%rbp),%eax
cltd
idivl  -0x10(%rbp)
cmp    $0x0,%edx
je     1167 <get_smallest_number+0x57>
movl   $0x0,-0xc(%rbp)
jmp    117c <get_smallest_number+0x6c>
movl   $0x1,-0xc(%rbp)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    113f <get_smallest_number+0x2f>
cmpl   $0x0,-0xc(%rbp)
je     118f <get_smallest_number+0x7f>
mov    -0x8(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1138 <get_smallest_number+0x28>

x86 assembly (clang, -O2):
<get_smallest_number>:
push   %rbp
push   %rbx
push   %rax
mov    %edi,%ebp
lea    0xee4(%rip),%rdi
mov    %ebp,%esi
call   1030 <printf@plt>
mov    %ebp,%esi
neg    %esi
mov    $0x1,%eax
mov    $0x1,%edi
jmp    114c <get_smallest_number+0x3c>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
lea    0x1(%rcx),%eax
test   %edi,%edi
mov    $0x0,%edi
jne    117e <get_smallest_number+0x6e>
mov    %eax,%ecx
test   %ebp,%ebp
jle    1140 <get_smallest_number+0x30>
mov    $0x1,%ebx
nopw   0x0(%rax,%rax,1)
xor    %edi,%edi
mov    %ecx,%eax
xor    %edx,%edx
div    %ebx
test   %edx,%edx
jne    1140 <get_smallest_number+0x30>
lea    (%rsi,%rbx,1),%eax
add    $0x1,%eax
mov    %ebx,%edx
add    $0x1,%edx
mov    %edx,%ebx
cmp    $0x1,%eax
jne    1160 <get_smallest_number+0x50>
mov    %ecx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [30 x i8] c"start with max_num == %i ... \00"
define i32 @get_smallest_number(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 %0, i32* %2
%6 = load i32, i32* %2
%7 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i32 %6)
store i32 1, i32* %3
store i32 1, i32* %4
br label %8
8: ; preds = %1, %28
store i32 1, i32* %5
br label %9
9: ; preds = %20, %8
%10 = load i32, i32* %5
%11 = load i32, i32* %2
%12 = icmp sle i32 %10, %11
br i1 %12, label %13, label %23
13: ; preds = %9
%14 = load i32, i32* %3
%15 = load i32, i32* %5
%16 = srem i32 %14, %15
%17 = icmp ne i32 %16, 0
br i1 %17, label %18, label %19
18: ; preds = %13
store i32 0, i32* %4
br label %23
19: ; preds = %13
store i32 1, i32* %4
br label %20
20: ; preds = %19
%21 = load i32, i32* %5
%22 = add nsw i32 %21, 1
store i32 %22, i32* %5
br label %9
23: ; preds = %18, %9
%24 = load i32, i32* %4
%25 = icmp ne i32 %24, 0
br i1 %25, label %26, label %28
26: ; preds = %23
%27 = load i32, i32* %3
ret i32 %27
28: ; preds = %23
%29 = load i32, i32* %3
%30 = add nsw i32 %29, 1
store i32 %30, i32* %3
br label %8
}

LLVM IR (-O2):
@.str = [30 x i8] c"start with max_num == %i ... \00"
define i32 @get_smallest_number(i32 %0) {
%2 = tail call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i32 %0)
%3 = icmp slt i32 %0, 1
br label %4
4: ; preds = %14, %1
%5 = phi i32 [ 1, %1 ], [ %17, %14 ]
%6 = phi i32 [ 1, %1 ], [ 0, %14 ]
br i1 %3, label %14, label %10
7: ; preds = %10
%8 = add nuw i32 %11, 1
%9 = icmp eq i32 %11, %0
br i1 %9, label %18, label %10
10: ; preds = %4, %7
%11 = phi i32 [ %8, %7 ], [ 1, %4 ]
%12 = urem i32 %5, %11
%13 = icmp eq i32 %12, 0
br i1 %13, label %7, label %14
14: ; preds = %10, %4
%15 = phi i32 [ %6, %4 ], [ 0, %10 ]
%16 = icmp eq i32 %15, 0
%17 = add nuw nsw i32 %5, 1
br i1 %16, label %4, label %18
18: ; preds = %14, %7
ret i32 %5
}