#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*/ parallel(int);
int /*<<< orphan*/ print_usage(int, char **);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ pthread_exit(int /*<<< orphan*/ *);
int /*<<< orphan*/ serial(int);
int /*<<< orphan*/ strcmp(char *, char *);
int main(int argc, char *argv[]) {
  if (argc != 3) {
    print_usage(argc, argv);
  }
  int num_tasks = atoi(argv[2]);
  if (!strcmp(argv[1], "serial")) {
    serial(num_tasks);
  } else if (!strcmp(argv[1], "parallel")) {
    parallel(num_tasks);
  } else {
    print_usage(argc, argv);
  }
  printf("Main completed\n");
  pthread_exit(NULL);
}


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)
cmpl   $0x3,-0x8(%rbp)
je     119c <main+0x2c>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1090 <print_usage@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1080 <atoi@plt>
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe45(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
jne    11d6 <main+0x66>
mov    -0x14(%rbp),%edi
call   1030 <serial@plt>
jmp    1211 <main+0xa1>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe22(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
jne    1200 <main+0x90>
mov    -0x14(%rbp),%edi
call   1060 <parallel@plt>
jmp    120c <main+0x9c>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1090 <print_usage@plt>
jmp    1211 <main+0xa1>
lea    0xdf8(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
mov    %eax,%edi
call   1070 <pthread_exit@plt>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %edi,%r15d
cmp    $0x3,%edi
je     118d <main+0x1d>
mov    %r15d,%edi
mov    %rbx,%rsi
call   1090 <print_usage@plt>
mov    0x10(%rbx),%rdi
call   1080 <atoi@plt>
mov    %eax,%r14d
mov    0x8(%rbx),%rbp
lea    0xe5c(%rip),%rsi
mov    %rbp,%rdi
call   1050 <strcmp@plt>
test   %eax,%eax
je     11d0 <main+0x60>
lea    0xe50(%rip),%rsi
mov    %rbp,%rdi
call   1050 <strcmp@plt>
test   %eax,%eax
je     11da <main+0x6a>
mov    %r15d,%edi
mov    %rbx,%rsi
call   1090 <print_usage@plt>
jmp    11e2 <main+0x72>
mov    %r14d,%edi
call   1040 <serial@plt>
jmp    11e2 <main+0x72>
mov    %r14d,%edi
call   1060 <parallel@plt>
lea    0xe27(%rip),%rdi
call   1030 <puts@plt>
xor    %edi,%edi
call   1070 <pthread_exit@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [7 x i8] c"serial\00"
@.str.1 = [9 x i8] c"parallel\00"
@.str.2 = [16 x i8] c"Main completed\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = load i32, i32* %4
%8 = icmp ne i32 %7, 3
br i1 %8, label %9, label %13
9: ; preds = %2
%10 = load i32, i32* %4
%11 = load i8**, i8*** %5
%12 = call i32 @print_usage(i32 %10, i8** %11)
br label %13
13: ; preds = %9, %2
%14 = load i8**, i8*** %5
%15 = getelementptr inbounds i8*, i8** %14, i64 2
%16 = load i8*, i8** %15
%17 = call i32 @atoi(i8* %16)
store i32 %17, i32* %6
%18 = load i8**, i8*** %5
%19 = getelementptr inbounds i8*, i8** %18, i64 1
%20 = load i8*, i8** %19
%21 = call i32 @strcmp(i8* %20, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%22 = icmp ne i32 %21, 0
br i1 %22, label %26, label %23
23: ; preds = %13
%24 = load i32, i32* %6
%25 = call i32 @serial(i32 %24)
br label %40
26: ; preds = %13
%27 = load i8**, i8*** %5
%28 = getelementptr inbounds i8*, i8** %27, i64 1
%29 = load i8*, i8** %28
%30 = call i32 @strcmp(i8* %29, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%31 = icmp ne i32 %30, 0
br i1 %31, label %35, label %32
32: ; preds = %26
%33 = load i32, i32* %6
%34 = call i32 @parallel(i32 %33)
br label %39
35: ; preds = %26
%36 = load i32, i32* %4
%37 = load i8**, i8*** %5
%38 = call i32 @print_usage(i32 %36, i8** %37)
br label %39
39: ; preds = %35, %32
br label %40
40: ; preds = %39, %23
%41 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0))
%42 = call i32 @pthread_exit(i32* null)
%43 = load i32, i32* %3
ret i32 %43
}

LLVM IR (-O2):
@.str = [7 x i8] c"serial\00"
@.str.1 = [9 x i8] c"parallel\00"
@str = [15 x i8] c"Main completed\00"
define i32 @main(i32 %0, i8** %1) {
%3 = icmp eq i32 %0, 3
br i1 %3, label %6, label %4
4: ; preds = %2
%5 = tail call i32 @print_usage(i32 %0, i8** %1)
br label %6
6: ; preds = %4, %2
%7 = getelementptr inbounds i8*, i8** %1, i64 2
%8 = load i8*, i8** %7
%9 = tail call i32 @atoi(i8* %8)
%10 = getelementptr inbounds i8*, i8** %1, i64 1
%11 = load i8*, i8** %10
%12 = tail call i32 @strcmp(i8* dereferenceable(1) %11, i8* dereferenceable(7) getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%13 = icmp eq i32 %12, 0
br i1 %13, label %14, label %16
14: ; preds = %6
%15 = tail call i32 @serial(i32 %9)
br label %23
16: ; preds = %6
%17 = tail call i32 @strcmp(i8* dereferenceable(1) %11, i8* dereferenceable(9) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%18 = icmp eq i32 %17, 0
br i1 %18, label %19, label %21
19: ; preds = %16
%20 = tail call i32 @parallel(i32 %9)
br label %23
21: ; preds = %16
%22 = tail call i32 @print_usage(i32 %0, i8** %1)
br label %23
23: ; preds = %19, %21, %14
%24 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str, i64 0, i64 0))
%25 = tail call i32 @pthread_exit(i32* null)
ret i32 0
}