#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 atoi(char *);
unsigned long gcd(unsigned long, int);
int /*<<< orphan*/ printf(char *, unsigned long, ...);
int main(int argc, char *argv[]) {
  int n, i;
  unsigned long result;
  if (argc == 1) {
    return 1;
  } else {
    n = atoi(argv[1]);
  }
  result = 2;
  for (i = 3; i < n + 1; i++) {
    printf("LCM of %d and %d: ", result, i);
    result = (result * i) / gcd(result, i);
    printf("%d\n", result);
  }
  printf("The GCF is: %d\n", result);
}


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)
cmpl   $0x1,-0x8(%rbp)
jne    115c <main+0x2c>
movl   $0x1,-0x4(%rbp)
jmp    11ff <main+0xcf>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1050 <atoi@plt>
mov    %eax,-0x14(%rbp)
movq   $0x2,-0x20(%rbp)
movl   $0x3,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    -0x14(%rbp),%ecx
add    $0x1,%ecx
cmp    %ecx,%eax
jge    11ed <main+0xbd>
mov    -0x20(%rbp),%rsi
mov    -0x18(%rbp),%edx
lea    0xe66(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x20(%rbp),%rax
movslq -0x18(%rbp),%rcx
imul   %rcx,%rax
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%esi
call   1040 <gcd@plt>
mov    %rax,%rcx
mov    -0x28(%rbp),%rax
xor    %edx,%edx
div    %rcx
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rsi
lea    0xe47(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    117b <main+0x4b>
mov    -0x20(%rbp),%rsi
lea    0xe1b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    $0x1,%ebx
cmp    $0x1,%edi
je     116c <main+0x3c>
mov    0x8(%rsi),%rdi
call   1050 <atoi@plt>
mov    $0x2,%r13d
cmp    $0x3,%eax
jge    117d <main+0x4d>
lea    0xeb3(%rip),%rdi
xor    %ebx,%ebx
mov    %r13,%rsi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %eax,%r14d
add    $0x1,%r14d
mov    $0x2,%r13d
mov    $0x3,%ebx
lea    0xe6a(%rip),%r15
lea    0xe82(%rip),%r12
jmp    11c1 <main+0x91>
nop
mov    %rbp,%rax
xor    %edx,%edx
div    %rcx
mov    %rax,%r13
mov    %r12,%rdi
mov    %r13,%rsi
xor    %eax,%eax
call   1030 <printf@plt>
add    $0x1,%rbx
cmp    %rbx,%r14
je     1159 <main+0x29>
mov    %r15,%rdi
mov    %r13,%rsi
mov    %ebx,%edx
xor    %eax,%eax
call   1030 <printf@plt>
mov    %r13,%rbp
imul   %rbx,%rbp
mov    %r13,%rdi
mov    %ebx,%esi
call   1040 <gcd@plt>
mov    %rax,%rcx
or     %rbp,%rax
shr    $0x20,%rax
jne    11a0 <main+0x70>
mov    %ebp,%eax
xor    %edx,%edx
div    %ecx
mov    %eax,%r13d
jmp    11ab <main+0x7b>

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

LLVM IR (-O2):
@.str = [19 x i8] c"LCM of %d and %d: \00"
@.str.1 = [4 x i8] c"%d\0A\00"
@.str.2 = [16 x i8] c"The GCF is: %d\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 1
br i1 %3, label %26, label %4
4: ; preds = %2
%5 = getelementptr inbounds i8*, i8** %1, i64 1
%6 = load i8*, i8** %5
%7 = tail call i32 @atoi(i8* %6)
%8 = icmp slt i32 %7, 3
br i1 %8, label %23, label %9
9: ; preds = %4
%10 = add nuw i32 %7, 1
%11 = zext i32 %10 to i64
br label %12
12: ; preds = %9, %12
%13 = phi i64 [ 3, %9 ], [ %21, %12 ]
%14 = phi i64 [ 2, %9 ], [ %19, %12 ]
%15 = trunc i64 %13 to i32
%16 = tail call i32 (i8*, i64, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i64 %14, i32 %15)
%17 = mul i64 %14, %13
%18 = tail call i64 @gcd(i64 %14, i32 %15)
%19 = udiv i64 %17, %18
%20 = tail call i32 (i8*, i64, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i64 %19)
%21 = add nuw nsw i64 %13, 1
%22 = icmp eq i64 %21, %11
br i1 %22, label %23, label %12
23: ; preds = %12, %4
%24 = phi i64 [ 2, %4 ], [ %19, %12 ]
%25 = tail call i32 (i8*, i64, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i64 %24)
br label %26
26: ; preds = %2, %23
%27 = phi i32 [ 0, %23 ], [ 1, %2 ]
ret i32 %27
}