#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 *);
int clamp(int, int /*<<< orphan*/, int);
int /*<<< orphan*/ dist(int, int);
int main(int argc, char *argv[]) {
  int iters = 10;
  int mask = 2;
  if (argc >= 2)
    mask = atoi(argv[1]);
  if (argc >= 3)
    iters = atoi(argv[2]);
  mask = clamp(mask, 0, 255);
  dist(mask, iters);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0xa,-0x14(%rbp)
movl   $0x2,-0x18(%rbp)
cmpl   $0x2,-0x8(%rbp)
jl     116e <main+0x3e>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1050 <atoi@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x3,-0x8(%rbp)
jl     1188 <main+0x58>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1050 <atoi@plt>
mov    %eax,-0x14(%rbp)
mov    -0x18(%rbp),%edi
xor    %esi,%esi
mov    $0xff,%edx
call   1030 <clamp@plt>
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%edi
mov    -0x14(%rbp),%esi
call   1040 <dist@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    $0xa,%r14d
mov    $0x2,%ebp
cmp    $0x2,%edi
jl     1168 <main+0x38>
mov    %rsi,%r15
mov    %edi,%ebx
mov    0x8(%rsi),%rdi
call   1050 <atoi@plt>
mov    %eax,%ebp
cmp    $0x2,%ebx
je     1168 <main+0x38>
mov    0x10(%r15),%rdi
call   1050 <atoi@plt>
mov    %eax,%r14d
mov    %ebp,%edi
xor    %esi,%esi
mov    $0xff,%edx
call   1030 <clamp@plt>
mov    %eax,%edi
mov    %r14d,%esi
call   1040 <dist@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 10, i32* %6
store i32 2, i32* %7
%8 = load i32, i32* %4
%9 = icmp sge i32 %8, 2
br i1 %9, label %10, label %15
10: ; preds = %2
%11 = load i8**, i8*** %5
%12 = getelementptr inbounds i8*, i8** %11, i64 1
%13 = load i8*, i8** %12
%14 = call i32 @atoi(i8* %13)
store i32 %14, i32* %7
br label %15
15: ; preds = %10, %2
%16 = load i32, i32* %4
%17 = icmp sge i32 %16, 3
br i1 %17, label %18, label %23
18: ; preds = %15
%19 = load i8**, i8*** %5
%20 = getelementptr inbounds i8*, i8** %19, i64 2
%21 = load i8*, i8** %20
%22 = call i32 @atoi(i8* %21)
store i32 %22, i32* %6
br label %23
23: ; preds = %18, %15
%24 = load i32, i32* %7
%25 = call i32 @clamp(i32 %24, i32 0, i32 255)
store i32 %25, i32* %7
%26 = load i32, i32* %7
%27 = load i32, i32* %6
%28 = call i32 @dist(i32 %26, i32 %27)
ret i32 0
}

LLVM IR (-O2):
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp sgt i32 %0, 1
br i1 %3, label %4, label %13
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 eq i32 %0, 2
br i1 %8, label %13, label %9
9: ; preds = %4
%10 = getelementptr inbounds i8*, i8** %1, i64 2
%11 = load i8*, i8** %10
%12 = tail call i32 @atoi(i8* %11)
br label %13
13: ; preds = %2, %9, %4
%14 = phi i32 [ %7, %9 ], [ %7, %4 ], [ 2, %2 ]
%15 = phi i32 [ %12, %9 ], [ 10, %4 ], [ 10, %2 ]
%16 = tail call i32 @clamp(i32 %14, i32 0, i32 255)
%17 = tail call i32 @dist(i32 %16, i32 %15)
ret i32 0
}