#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 */
typedef int /*<<< orphan*/ uint32_t;

/* Variables and functions */
int EX_USAGE;
scalar_t__ atoi(char *);
int /*<<< orphan*/ isdigit(char);
int print_all_progs();
int print_one_prog(int /*<<< orphan*/);
int /*<<< orphan*/ usage();
int main(int argc, char **argv) {
  if (argc > 1) {
    if (!isdigit(*argv[1])) {
      usage();
      return EX_USAGE;
    }
    return print_one_prog((uint32_t)atoi(argv[1]));
  }
  return print_all_progs();
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x1,-0x8(%rbp)
jle    11bd <main+0x6d>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
movsbl (%rax),%edi
call   1030 <isdigit@plt>
cmp    $0x0,%eax
jne    11a1 <main+0x51>
mov    $0x0,%al
call   1060 <usage@plt>
mov    0x2e51(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    11c7 <main+0x77>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1070 <atoi@plt>
mov    %eax,%edi
call   1050 <print_one_prog@plt>
mov    %eax,-0x4(%rbp)
jmp    11c7 <main+0x77>
mov    $0x0,%al
call   1040 <print_all_progs@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
cmp    $0x2,%edi
jl     117a <main+0x2a>
mov    %rsi,%rbx
mov    0x8(%rsi),%rax
movsbl (%rax),%edi
call   1030 <isdigit@plt>
test   %eax,%eax
je     1182 <main+0x32>
mov    0x8(%rbx),%rdi
call   1070 <atoi@plt>
mov    %eax,%edi
pop    %rbx
jmp    1050 <print_one_prog@plt>
xor    %eax,%eax
pop    %rbx
jmp    1040 <print_all_progs@plt>
xor    %eax,%eax
call   1060 <usage@plt>
mov    0x2e58(%rip),%rax
mov    (%rax),%eax
pop    %rbx
ret

LLVM IR (-O0):
@EX_USAGE = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%6 = load i32, i32* %4
%7 = icmp sgt i32 %6, 1
br i1 %7, label %8, label %25
8: ; preds = %2
%9 = load i8**, i8*** %5
%10 = getelementptr inbounds i8*, i8** %9, i64 1
%11 = load i8*, i8** %10
%12 = load i8, i8* %11
%13 = call i32 @isdigit(i8 signext %12)
%14 = icmp ne i32 %13, 0
br i1 %14, label %18, label %15
15: ; preds = %8
%16 = call i32 (...) @usage()
%17 = load i32, i32* @EX_USAGE
store i32 %17, i32* %3
br label %27
18: ; preds = %8
%19 = load i8**, i8*** %5
%20 = getelementptr inbounds i8*, i8** %19, i64 1
%21 = load i8*, i8** %20
%22 = call i64 @atoi(i8* %21)
%23 = trunc i64 %22 to i32
%24 = call i32 @print_one_prog(i32 %23)
store i32 %24, i32* %3
br label %27
25: ; preds = %2
%26 = call i32 (...) @print_all_progs()
store i32 %26, i32* %3
br label %27
27: ; preds = %25, %18, %15
%28 = load i32, i32* %3
ret i32 %28
}

LLVM IR (-O2):
@EX_USAGE = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp sgt i32 %0, 1
br i1 %3, label %4, label %18
4: ; preds = %2
%5 = getelementptr inbounds i8*, i8** %1, i64 1
%6 = load i8*, i8** %5
%7 = load i8, i8* %6
%8 = tail call i32 @isdigit(i8 signext %7)
%9 = icmp eq i32 %8, 0
br i1 %9, label %10, label %13
10: ; preds = %4
%11 = tail call i32 (...) @usage()
%12 = load i32, i32* @EX_USAGE
br label %20
13: ; preds = %4
%14 = load i8*, i8** %5
%15 = tail call i64 @atoi(i8* %14)
%16 = trunc i64 %15 to i32
%17 = tail call i32 @print_one_prog(i32 %16)
br label %20
18: ; preds = %2
%19 = tail call i32 (...) @print_all_progs()
br label %20
20: ; preds = %18, %13, %10
%21 = phi i32 [ %17, %13 ], [ %12, %10 ], [ %19, %18 ]
ret i32 %21
}