#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 */
long atol(char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
long gcd(long, long);
int /*<<< orphan*/ printf(char *, long);
int /*<<< orphan*/ stderr;
int main(int argc, char *argv[]) {
  long result;
  int i;
  if (argc <= 1) {
    fprintf(stderr, "Usage: gcd VAL1 VAL2 ... VALN\n");
    return 1;
  }
  result = atol(argv[1]);
  for (i = 2; i < argc; i++) {
    result = gcd(result, atol(argv[i]));
  }
  printf("%ld\n", result);
  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)
cmpl   $0x1,-0x8(%rbp)
jg     1181 <main+0x41>
mov    0x2e79(%rip),%rax
mov    (%rax),%edi
lea    0xe90(%rip),%rsi
call   1040 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    11f3 <main+0xb3>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1050 <atol@plt>
mov    %rax,-0x18(%rbp)
movl   $0x2,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11dc <main+0x9c>
mov    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1050 <atol@plt>
mov    -0x28(%rbp),%rdi
mov    %rax,%rsi
call   1060 <gcd@plt>
mov    %rax,-0x18(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1199 <main+0x59>
mov    -0x18(%rbp),%rsi
lea    0xe38(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
cmp    $0x1,%edi
jg     1168 <main+0x28>
mov    0x2e8d(%rip),%rax
mov    (%rax),%edi
lea    0xea4(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0x1,%eax
jmp    11c1 <main+0x81>
mov    %rsi,%r14
mov    %edi,%ebp
mov    0x8(%rsi),%rdi
call   1050 <atol@plt>
mov    %rax,%rbx
cmp    $0x2,%ebp
je     11b0 <main+0x70>
mov    %ebp,%r15d
mov    $0x2,%ebp
cs nopw 0x0(%rax,%rax,1)
mov    (%r14,%rbp,8),%rdi
call   1050 <atol@plt>
mov    %rbx,%rdi
mov    %rax,%rsi
call   1060 <gcd@plt>
mov    %rax,%rbx
add    $0x1,%rbp
cmp    %rbp,%r15
jne    1190 <main+0x50>
lea    0xe68(%rip),%rdi
mov    %rbx,%rsi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [31 x i8] c"Usage: gcd VAL1 VAL2 ... VALN\0A\00"
@.str.1 = [5 x i8] c"%ld\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i64
%7 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = load i32, i32* %4
%9 = icmp sle i32 %8, 1
br i1 %9, label %10, label %13
10: ; preds = %2
%11 = load i32, i32* @stderr
%12 = call i32 @fprintf(i32 %11, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %3
br label %37
13: ; preds = %2
%14 = load i8**, i8*** %5
%15 = getelementptr inbounds i8*, i8** %14, i64 1
%16 = load i8*, i8** %15
%17 = call i64 @atol(i8* %16)
store i64 %17, i64* %6
store i32 2, i32* %7
br label %18
18: ; preds = %31, %13
%19 = load i32, i32* %7
%20 = load i32, i32* %4
%21 = icmp slt i32 %19, %20
br i1 %21, label %22, label %34
22: ; preds = %18
%23 = load i64, i64* %6
%24 = load i8**, i8*** %5
%25 = load i32, i32* %7
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds i8*, i8** %24, i64 %26
%28 = load i8*, i8** %27
%29 = call i64 @atol(i8* %28)
%30 = call i64 @gcd(i64 %23, i64 %29)
store i64 %30, i64* %6
br label %31
31: ; preds = %22
%32 = load i32, i32* %7
%33 = add nsw i32 %32, 1
store i32 %33, i32* %7
br label %18
34: ; preds = %18
%35 = load i64, i64* %6
%36 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i64 %35)
store i32 0, i32* %3
br label %37
37: ; preds = %34, %10
%38 = load i32, i32* %3
ret i32 %38
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [31 x i8] c"Usage: gcd VAL1 VAL2 ... VALN\0A\00"
@.str.1 = [5 x i8] c"%ld\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp slt i32 %0, 2
br i1 %3, label %4, label %7
4: ; preds = %2
%5 = load i32, i32* @stderr
%6 = tail call i32 @fprintf(i32 %5, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0))
br label %26
7: ; preds = %2
%8 = getelementptr inbounds i8*, i8** %1, i64 1
%9 = load i8*, i8** %8
%10 = tail call i64 @atol(i8* %9)
%11 = icmp eq i32 %0, 2
br i1 %11, label %23, label %12
12: ; preds = %7
%13 = zext i32 %0 to i64
br label %14
14: ; preds = %12, %14
%15 = phi i64 [ 2, %12 ], [ %21, %14 ]
%16 = phi i64 [ %10, %12 ], [ %20, %14 ]
%17 = getelementptr inbounds i8*, i8** %1, i64 %15
%18 = load i8*, i8** %17
%19 = tail call i64 @atol(i8* %18)
%20 = tail call i64 @gcd(i64 %16, i64 %19)
%21 = add nuw nsw i64 %15, 1
%22 = icmp eq i64 %21, %13
br i1 %22, label %23, label %14
23: ; preds = %14, %7
%24 = phi i64 [ %10, %7 ], [ %20, %14 ]
%25 = tail call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i64 %24)
br label %26
26: ; preds = %23, %4
%27 = phi i32 [ 1, %4 ], [ 0, %23 ]
ret i32 %27
}