#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 /*<<< orphan*/ free(char *);
char *malloc(scalar_t__);
int man(char *);
int /*<<< orphan*/ sprintf(char *, char *, char *, char *);
scalar_t__ strlen(char *);
int /*<<< orphan*/ usage(char *);
int main(int argc, char *argv[]) {
  char *pc;
  int r;
  if (argc == 2) {
    r = man(argv[1]);
  } else if (argc == 3) {
    pc = malloc(strlen(argv[1]) + strlen(argv[2]) + 2);
    sprintf(pc, "%s/%s", argv[1], argv[2]);
    r = man(pc);
    free(pc);
  } else {
    usage(argv[0]);
    return 1;
  }
  if (r)
    usage(argv[0]);
  return r;
}


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   $0x2,-0x8(%rbp)
jne    1195 <main+0x35>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1050 <man@plt>
mov    %eax,-0x1c(%rbp)
jmp    1228 <main+0xc8>
cmpl   $0x3,-0x8(%rbp)
jne    120b <main+0xab>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1040 <strlen@plt>
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1040 <strlen@plt>
mov    -0x28(%rbp),%rdi
add    %rax,%rdi
add    $0x2,%rdi
call   1060 <malloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rcx
lea    0xe14(%rip),%rsi
call   1080 <sprintf@plt>
mov    -0x18(%rbp),%rdi
call   1050 <man@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
jmp    1223 <main+0xc3>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1070 <usage@plt>
movl   $0x1,-0x4(%rbp)
jmp    1244 <main+0xe4>
jmp    1228 <main+0xc8>
cmpl   $0x0,-0x1c(%rbp)
je     123e <main+0xde>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1070 <usage@plt>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rsi,%r12
cmp    $0x3,%edi
je     1195 <main+0x35>
mov    $0x1,%ebp
cmp    $0x2,%edi
jne    118a <main+0x2a>
mov    0x8(%r12),%rdi
call   1050 <man@plt>
mov    %eax,%ebp
test   %ebp,%ebp
je     11ed <main+0x8d>
mov    (%r12),%rdi
call   1070 <usage@plt>
jmp    11ef <main+0x8f>
mov    0x8(%r12),%r15
mov    %r15,%rdi
call   1040 <strlen@plt>
mov    %rax,%r14
mov    0x10(%r12),%rbp
mov    %rbp,%rdi
call   1040 <strlen@plt>
lea    (%r14,%rax,1),%rdi
add    $0x2,%rdi
call   1060 <malloc@plt>
mov    %rax,%rbx
lea    0xe37(%rip),%rsi
mov    %rax,%rdi
mov    %r15,%rdx
mov    %rbp,%rcx
call   1080 <sprintf@plt>
mov    %rbx,%rdi
call   1050 <man@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1030 <free@plt>
test   %ebp,%ebp
jne    118a <main+0x2a>
xor    %ebp,%ebp
mov    %ebp,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [6 x i8] c"%s/%s\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = load i32, i32* %4
%9 = icmp eq 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 @man(i8* %13)
store i32 %14, i32* %7
br label %48
15: ; preds = %2
%16 = load i32, i32* %4
%17 = icmp eq i32 %16, 3
br i1 %17, label %18, label %42
18: ; preds = %15
%19 = load i8**, i8*** %5
%20 = getelementptr inbounds i8*, i8** %19, i64 1
%21 = load i8*, i8** %20
%22 = call i64 @strlen(i8* %21)
%23 = load i8**, i8*** %5
%24 = getelementptr inbounds i8*, i8** %23, i64 2
%25 = load i8*, i8** %24
%26 = call i64 @strlen(i8* %25)
%27 = add nsw i64 %22, %26
%28 = add nsw i64 %27, 2
%29 = call i8* @malloc(i64 %28)
store i8* %29, i8** %6
%30 = load i8*, i8** %6
%31 = load i8**, i8*** %5
%32 = getelementptr inbounds i8*, i8** %31, i64 1
%33 = load i8*, i8** %32
%34 = load i8**, i8*** %5
%35 = getelementptr inbounds i8*, i8** %34, i64 2
%36 = load i8*, i8** %35
%37 = call i32 @sprintf(i8* %30, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %33, i8* %36)
%38 = load i8*, i8** %6
%39 = call i32 @man(i8* %38)
store i32 %39, i32* %7
%40 = load i8*, i8** %6
%41 = call i32 @free(i8* %40)
br label %47
42: ; preds = %15
%43 = load i8**, i8*** %5
%44 = getelementptr inbounds i8*, i8** %43, i64 0
%45 = load i8*, i8** %44
%46 = call i32 @usage(i8* %45)
store i32 1, i32* %3
br label %58
47: ; preds = %18
br label %48
48: ; preds = %47, %10
%49 = load i32, i32* %7
%50 = icmp ne i32 %49, 0
br i1 %50, label %51, label %56
51: ; preds = %48
%52 = load i8**, i8*** %5
%53 = getelementptr inbounds i8*, i8** %52, i64 0
%54 = load i8*, i8** %53
%55 = call i32 @usage(i8* %54)
br label %56
56: ; preds = %51, %48
%57 = load i32, i32* %7
store i32 %57, i32* %3
br label %58
58: ; preds = %56, %42
%59 = load i32, i32* %3
ret i32 %59
}

LLVM IR (-O2):
@.str = [6 x i8] c"%s/%s\00"
define i32 @main(i32 %0, i8** nocapture %1) {
switch i32 %0, label %23 [
i32 2, label %3
i32 3, label %7
]
3: ; preds = %2
%4 = getelementptr inbounds i8*, i8** %1, i64 1
%5 = load i8*, i8** %4
%6 = tail call i32 @man(i8* %5)
br label %20
7: ; preds = %2
%8 = getelementptr inbounds i8*, i8** %1, i64 1
%9 = load i8*, i8** %8
%10 = tail call i64 @strlen(i8* dereferenceable(1) %9)
%11 = getelementptr inbounds i8*, i8** %1, i64 2
%12 = load i8*, i8** %11
%13 = tail call i64 @strlen(i8* dereferenceable(1) %12)
%14 = add i64 %10, 2
%15 = add i64 %14, %13
%16 = tail call i8* @malloc(i64 %15)
%17 = tail call i32 @sprintf(i8* dereferenceable(1) %16, i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %9, i8* %12)
%18 = tail call i32 @man(i8* %16)
%19 = tail call i32 @free(i8* %16)
br label %20
20: ; preds = %7, %3
%21 = phi i32 [ %6, %3 ], [ %18, %7 ]
%22 = icmp eq i32 %21, 0
br i1 %22, label %27, label %23
23: ; preds = %20, %2
%24 = phi i32 [ 1, %2 ], [ %21, %20 ]
%25 = load i8*, i8** %1
%26 = tail call i32 @usage(i8* %25)
br label %27
27: ; preds = %23, %20
%28 = phi i32 [ 0, %20 ], [ %24, %23 ]
ret i32 %28
}