#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 /*<<< orphan*/ printf(char *, ...);
int main(int argc, char *argv[]) {
  char *navn = argv[0];
  if (argc != 3) {
    printf("\nBruk: %s t1 t2 \n", navn);
    printf("\n      hvor t1 og t2 er to heltall ");
    printf("som er > 0\n\n");
    printf("Programmet adderer to tall og ");
    printf("skriver summen ut paa skjermen.\n");
    return 1;
  }
  char *a = argv[1];
  char *b = argv[2];
  int t1 = atoi(a);
  if (t1 == 0) {
    printf("\nFeil: t1 maa vaere et heltall > 0\n");
    return 1;
  }
  int t2 = atoi(b);
  if (t2 == 0) {
    printf("\nFeil: t2 maa vaere et heltall > 0\n");
    return 1;
  }
  int t3 = t1 + t2;
  printf("Summen av %d og %d er %d\n", t1, t2, t3);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x18(%rbp)
cmpl   $0x3,-0x8(%rbp)
je     11a1 <main+0x81>
mov    -0x18(%rbp),%rsi
lea    0xeaa(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeae(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xec4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xec3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xed4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1240 <main+0x120>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rdi
call   1040 <atoi@plt>
mov    %eax,-0x2c(%rbp)
cmpl   $0x0,-0x2c(%rbp)
jne    11e9 <main+0xc9>
lea    0xead(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1240 <main+0x120>
mov    -0x28(%rbp),%rdi
call   1040 <atoi@plt>
mov    %eax,-0x30(%rbp)
cmpl   $0x0,-0x30(%rbp)
jne    1219 <main+0xf9>
lea    0xea1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1240 <main+0x120>
mov    -0x2c(%rbp),%eax
add    -0x30(%rbp),%eax
mov    %eax,-0x34(%rbp)
mov    -0x2c(%rbp),%esi
mov    -0x30(%rbp),%edx
mov    -0x34(%rbp),%ecx
lea    0xe99(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
mov    %rsi,%rbp
cmp    $0x3,%edi
jne    1171 <main+0x41>
mov    0x8(%rbp),%rdi
call   1050 <atoi@plt>
test   %eax,%eax
je     11b4 <main+0x84>
mov    %eax,%ebx
mov    0x10(%rbp),%rdi
call   1050 <atoi@plt>
test   %eax,%eax
je     11bd <main+0x8d>
mov    %eax,%ecx
add    %ebx,%ecx
lea    0xef3(%rip),%rdi
xor    %ebp,%ebp
mov    %ebx,%esi
mov    %eax,%edx
xor    %eax,%eax
call   1040 <printf@plt>
jmp    11ce <main+0x9e>
mov    0x0(%rbp),%rsi
lea    0xe84(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe88(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xf1d(%rip),%rdi
call   1030 <puts@plt>
lea    0xe92(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xf0f(%rip),%rdi
jmp    11c4 <main+0x94>
lea    0xed7(%rip),%rdi
jmp    11c4 <main+0x94>
lea    0xeab(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [18 x i8] c"\0ABruk: %s t1 t2 \0A\00"
@.str.1 = [36 x i8] c"\0A hvor t1 og t2 er to heltall \00"
@.str.2 = [13 x i8] c"som er > 0\0A\0A\00"
@.str.3 = [31 x i8] c"Programmet adderer to tall og \00"
@.str.4 = [33 x i8] c"skriver summen ut paa skjermen.\0A\00"
@.str.5 = [36 x i8] c"\0AFeil: t1 maa vaere et heltall > 0\0A\00"
@.str.6 = [36 x i8] c"\0AFeil: t2 maa vaere et heltall > 0\0A\00"
@.str.7 = [26 x i8] c"Summen av %d og %d er %d\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%12 = load i8**, i8*** %5
%13 = getelementptr inbounds i8*, i8** %12, i64 0
%14 = load i8*, i8** %13
store i8* %14, i8** %6
%15 = load i32, i32* %4
%16 = icmp ne i32 %15, 3
br i1 %16, label %17, label %24
17: ; preds = %2
%18 = load i8*, i8** %6
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* %18)
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.1, i64 0, i64 0))
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0))
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0))
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.4, i64 0, i64 0))
store i32 1, i32* %3
br label %52
24: ; preds = %2
%25 = load i8**, i8*** %5
%26 = getelementptr inbounds i8*, i8** %25, i64 1
%27 = load i8*, i8** %26
store i8* %27, i8** %7
%28 = load i8**, i8*** %5
%29 = getelementptr inbounds i8*, i8** %28, i64 2
%30 = load i8*, i8** %29
store i8* %30, i8** %8
%31 = load i8*, i8** %7
%32 = call i32 @atoi(i8* %31)
store i32 %32, i32* %9
%33 = load i32, i32* %9
%34 = icmp eq i32 %33, 0
br i1 %34, label %35, label %37
35: ; preds = %24
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.5, i64 0, i64 0))
store i32 1, i32* %3
br label %52
37: ; preds = %24
%38 = load i8*, i8** %8
%39 = call i32 @atoi(i8* %38)
store i32 %39, i32* %10
%40 = load i32, i32* %10
%41 = icmp eq i32 %40, 0
br i1 %41, label %42, label %44
42: ; preds = %37
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.6, i64 0, i64 0))
store i32 1, i32* %3
br label %52
44: ; preds = %37
%45 = load i32, i32* %9
%46 = load i32, i32* %10
%47 = add nsw i32 %45, %46
store i32 %47, i32* %11
%48 = load i32, i32* %9
%49 = load i32, i32* %10
%50 = load i32, i32* %11
%51 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.7, i64 0, i64 0), i32 %48, i32 %49, i32 %50)
store i32 0, i32* %3
br label %52
52: ; preds = %44, %42, %35, %17
%53 = load i32, i32* %3
ret i32 %53
}

LLVM IR (-O2):
@.str = [18 x i8] c"\0ABruk: %s t1 t2 \0A\00"
@.str.1 = [36 x i8] c"\0A hvor t1 og t2 er to heltall \00"
@.str.3 = [31 x i8] c"Programmet adderer to tall og \00"
@.str.7 = [26 x i8] c"Summen av %d og %d er %d\0A\00"
@str = [35 x i8] c"\0AFeil: t2 maa vaere et heltall > 0\00"
@str.8 = [35 x i8] c"\0AFeil: t1 maa vaere et heltall > 0\00"
@str.9 = [12 x i8] c"som er > 0\0A\00"
@str.10 = [32 x i8] c"skriver summen ut paa skjermen.\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 3
br i1 %3, label %11, label %4
4: ; preds = %2
%5 = load i8*, i8** %1
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* %5)
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @.str.1, i64 0, i64 0))
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str.9, i64 0, i64 0))
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0))
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @str.10, i64 0, i64 0))
br label %28
11: ; preds = %2
%12 = getelementptr inbounds i8*, i8** %1, i64 1
%13 = load i8*, i8** %12
%14 = tail call i32 @atoi(i8* %13)
%15 = icmp eq i32 %14, 0
br i1 %15, label %16, label %18
16: ; preds = %11
%17 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @str.8, i64 0, i64 0))
br label %28
18: ; preds = %11
%19 = getelementptr inbounds i8*, i8** %1, i64 2
%20 = load i8*, i8** %19
%21 = tail call i32 @atoi(i8* %20)
%22 = icmp eq i32 %21, 0
br i1 %22, label %23, label %25
23: ; preds = %18
%24 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @str, i64 0, i64 0))
br label %28
25: ; preds = %18
%26 = add nsw i32 %21, %14
%27 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.7, i64 0, i64 0), i32 %14, i32 %21, i32 %26)
br label %28
28: ; preds = %16, %25, %23, %4
%29 = phi i32 [ 1, %4 ], [ 1, %16 ], [ 1, %23 ], [ 0, %25 ]
ret i32 %29
}