#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*/ routine(char *, char *, char, int);
int strlen(char *);
int /*<<< orphan*/ usage(char *, char *);
int main(int argc, char *argv[]) {
  if (argc != 4)
    usage(argv[0], NULL);
  else {
    char *filename = argv[1];
    char *byte = argv[2];
    int size = atoi(argv[3]);
    if (strlen(byte) != 1)
      usage(argv[0], "second argument must be a single character");
    if (size < 0)
      usage(argv[0], "size must be positive");
    routine(argv[0], filename, byte[0], size);
  }
}


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   $0x4,-0x8(%rbp)
je     1175 <main+0x35>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1050 <usage@plt>
jmp    11fb <main+0xbb>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
call   1060 <atoi@plt>
mov    %eax,-0x24(%rbp)
mov    -0x20(%rbp),%rdi
call   1030 <strlen@plt>
cmp    $0x1,%eax
je     11c2 <main+0x82>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
lea    0xe43(%rip),%rsi
call   1050 <usage@plt>
cmpl   $0x0,-0x24(%rbp)
jge    11df <main+0x9f>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
lea    0xe51(%rip),%rsi
call   1050 <usage@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rax
mov    (%rax),%al
mov    -0x24(%rbp),%ecx
movsbl %al,%edx
call   1040 <routine@plt>
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
mov    %rsi,%rbx
cmp    $0x4,%edi
jne    11a4 <main+0x64>
mov    0x8(%rbx),%r14
mov    0x10(%rbx),%r15
mov    0x18(%rbx),%rdi
call   1060 <atoi@plt>
mov    %eax,%ebp
mov    %r15,%rdi
call   1030 <strlen@plt>
cmp    $0x1,%eax
je     117e <main+0x3e>
mov    (%rbx),%rdi
lea    0xe87(%rip),%rsi
call   1050 <usage@plt>
test   %ebp,%ebp
jns    1191 <main+0x51>
mov    (%rbx),%rdi
lea    0xe9f(%rip),%rsi
call   1050 <usage@plt>
mov    (%rbx),%rdi
movsbl (%r15),%edx
mov    %r14,%rsi
mov    %ebp,%ecx
call   1040 <routine@plt>
jmp    11ae <main+0x6e>
mov    (%rbx),%rdi
xor    %esi,%esi
call   1050 <usage@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [43 x i8] c"second argument must be a single character\00"
@.str.1 = [22 x i8] c"size must be positive\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 i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = load i32, i32* %4
%10 = icmp ne i32 %9, 4
br i1 %10, label %11, label %16
11: ; preds = %2
%12 = load i8**, i8*** %5
%13 = getelementptr inbounds i8*, i8** %12, i64 0
%14 = load i8*, i8** %13
%15 = call i32 @usage(i8* %14, i8* null)
br label %53
16: ; preds = %2
%17 = load i8**, i8*** %5
%18 = getelementptr inbounds i8*, i8** %17, i64 1
%19 = load i8*, i8** %18
store i8* %19, i8** %6
%20 = load i8**, i8*** %5
%21 = getelementptr inbounds i8*, i8** %20, i64 2
%22 = load i8*, i8** %21
store i8* %22, i8** %7
%23 = load i8**, i8*** %5
%24 = getelementptr inbounds i8*, i8** %23, i64 3
%25 = load i8*, i8** %24
%26 = call i32 @atoi(i8* %25)
store i32 %26, i32* %8
%27 = load i8*, i8** %7
%28 = call i32 @strlen(i8* %27)
%29 = icmp ne i32 %28, 1
br i1 %29, label %30, label %35
30: ; preds = %16
%31 = load i8**, i8*** %5
%32 = getelementptr inbounds i8*, i8** %31, i64 0
%33 = load i8*, i8** %32
%34 = call i32 @usage(i8* %33, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str, i64 0, i64 0))
br label %35
35: ; preds = %30, %16
%36 = load i32, i32* %8
%37 = icmp slt i32 %36, 0
br i1 %37, label %38, label %43
38: ; preds = %35
%39 = load i8**, i8*** %5
%40 = getelementptr inbounds i8*, i8** %39, i64 0
%41 = load i8*, i8** %40
%42 = call i32 @usage(i8* %41, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0))
br label %43
43: ; preds = %38, %35
%44 = load i8**, i8*** %5
%45 = getelementptr inbounds i8*, i8** %44, i64 0
%46 = load i8*, i8** %45
%47 = load i8*, i8** %6
%48 = load i8*, i8** %7
%49 = getelementptr inbounds i8, i8* %48, i64 0
%50 = load i8, i8* %49
%51 = load i32, i32* %8
%52 = call i32 @routine(i8* %46, i8* %47, i8 signext %50, i32 %51)
br label %53
53: ; preds = %43, %11
%54 = load i32, i32* %3
ret i32 %54
}

LLVM IR (-O2):
@.str = [43 x i8] c"second argument must be a single character\00"
@.str.1 = [22 x i8] c"size must be positive\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 4
br i1 %3, label %7, label %4
4: ; preds = %2
%5 = load i8*, i8** %1
%6 = tail call i32 @usage(i8* %5, i8* null)
br label %29
7: ; preds = %2
%8 = getelementptr inbounds i8*, i8** %1, i64 1
%9 = load i8*, i8** %8
%10 = getelementptr inbounds i8*, i8** %1, i64 2
%11 = load i8*, i8** %10
%12 = getelementptr inbounds i8*, i8** %1, i64 3
%13 = load i8*, i8** %12
%14 = tail call i32 @atoi(i8* %13)
%15 = tail call i32 @strlen(i8* %11)
%16 = icmp eq i32 %15, 1
br i1 %16, label %20, label %17
17: ; preds = %7
%18 = load i8*, i8** %1
%19 = tail call i32 @usage(i8* %18, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str, i64 0, i64 0))
br label %20
20: ; preds = %17, %7
%21 = icmp slt i32 %14, 0
br i1 %21, label %22, label %25
22: ; preds = %20
%23 = load i8*, i8** %1
%24 = tail call i32 @usage(i8* %23, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0))
br label %25
25: ; preds = %22, %20
%26 = load i8*, i8** %1
%27 = load i8, i8* %11
%28 = tail call i32 @routine(i8* %26, i8* %9, i8 signext %27, i32 %14)
br label %29
29: ; preds = %25, %4
ret i32 0
}