#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 */
unsigned long gcd(unsigned long, unsigned long);
int /*<<< orphan*/ printf(char *, unsigned long);
int main() {
  unsigned long a = 1, i = 20;
  for (; i > 0; i--) {
    if (a % i) {
      a *= (i / gcd(a, i));
    }
  }
  printf("Problem 5: %lu\n", a);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movq   $0x1,-0x10(%rbp)
movq   $0x14,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jbe    11a0 <main+0x80>
mov    -0x10(%rbp),%rax
xor    %ecx,%ecx
mov    %ecx,%edx
divq   -0x18(%rbp)
cmp    $0x0,%rdx
je     118a <main+0x6a>
mov    -0x18(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1040 <gcd@plt>
mov    %rax,%rcx
mov    -0x20(%rbp),%rax
xor    %edx,%edx
div    %rcx
imul   -0x10(%rbp),%rax
mov    %rax,-0x10(%rbp)
jmp    118f <main+0x6f>
mov    -0x18(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x18(%rbp)
jmp    113f <main+0x1f>
mov    -0x10(%rbp),%rsi
lea    0xe55(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
mov    $0x1,%r14d
mov    $0x14,%ebx
jmp    1152 <main+0x32>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %rbx,%rax
xor    %edx,%edx
div    %rcx
imul   %rax,%r14
add    $0xffffffffffffffff,%rbx
je     119b <main+0x7b>
mov    %r14,%rax
or     %rbx,%rax
shr    $0x20,%rax
je     1170 <main+0x50>
mov    %r14,%rax
xor    %edx,%edx
div    %rbx
test   %rdx,%rdx
jne    117c <main+0x5c>
jmp    114c <main+0x2c>
nopl   (%rax)
mov    %r14d,%eax
xor    %edx,%edx
div    %ebx
test   %rdx,%rdx
je     114c <main+0x2c>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1040 <gcd@plt>
mov    %rax,%rcx
or     %rbx,%rax
shr    $0x20,%rax
jne    1140 <main+0x20>
mov    %ebx,%eax
xor    %edx,%edx
div    %ecx
jmp    1148 <main+0x28>
lea    0xe5e(%rip),%rdi
mov    %r14,%rsi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [16 x i8] c"Problem 5: %lu\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i64
%3 = alloca i64
store i32 0, i32* %1
store i64 1, i64* %2
store i64 20, i64* %3
br label %4
4: ; preds = %21, %0
%5 = load i64, i64* %3
%6 = icmp ugt i64 %5, 0
br i1 %6, label %7, label %24
7: ; preds = %4
%8 = load i64, i64* %2
%9 = load i64, i64* %3
%10 = urem i64 %8, %9
%11 = icmp ne i64 %10, 0
br i1 %11, label %12, label %20
12: ; preds = %7
%13 = load i64, i64* %3
%14 = load i64, i64* %2
%15 = load i64, i64* %3
%16 = call i64 @gcd(i64 %14, i64 %15)
%17 = udiv i64 %13, %16
%18 = load i64, i64* %2
%19 = mul i64 %18, %17
store i64 %19, i64* %2
br label %20
20: ; preds = %12, %7
br label %21
21: ; preds = %20
%22 = load i64, i64* %3
%23 = add i64 %22, -1
store i64 %23, i64* %3
br label %4
24: ; preds = %4
%25 = load i64, i64* %2
%26 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i64 %25)
ret i32 0
}

LLVM IR (-O2):
@.str = [16 x i8] c"Problem 5: %lu\0A\00"
define i32 @main() {
br label %1
1: ; preds = %0, %10
%2 = phi i64 [ 20, %0 ], [ %12, %10 ]
%3 = phi i64 [ 1, %0 ], [ %11, %10 ]
%4 = urem i64 %3, %2
%5 = icmp eq i64 %4, 0
br i1 %5, label %10, label %6
6: ; preds = %1
%7 = tail call i64 @gcd(i64 %3, i64 %2)
%8 = udiv i64 %2, %7
%9 = mul i64 %8, %3
br label %10
10: ; preds = %1, %6
%11 = phi i64 [ %9, %6 ], [ %3, %1 ]
%12 = add nsw i64 %2, -1
%13 = icmp eq i64 %12, 0
br i1 %13, label %14, label %1
14: ; preds = %10
%15 = tail call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i64 %11)
ret i32 0
}