#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*/ fprintf(int /*<<< orphan*/, char *, ...);
int printx(char *, char *, ...);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ strcmp(char *, char *);
int /*<<< orphan*/ usage(char *);
int main(int argc, char **argv) {
  if (argc < 2) {
    usage(argv[0]);
    return -1;
  }
  if (argv[2][0] != '/') {
    fprintf(
        stderr,
        "filename must begin with '/' as any sane URL! (e.g. /index.html)\n");
    return -1;
  }
  if (!strcmp(argv[1], "-0")) {
    return printx("GET %s HTTP/1.0\r\n\r\n", argv[2]);
  }
  if (!strcmp(argv[1], "-1")) {
    if (argc != 4) {
      fprintf(stderr, "missing <host>, required parameter for HTTP/1.1 header! "
                      "(e.g. www.tty64.org)\n");
      return -1;
    }
    return printx("GET %s HTTP/1.1\r\nHost: %s\r\n\r\n", argv[2], argv[3]);
  }
  fprintf(stderr, "%s: unknown http protocol, try -0 or -1\n", argv[1]);
  return -1;
}


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   $0x2,-0x8(%rbp)
jge    1178 <main+0x38>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1060 <usage@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1280 <main+0x140>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
movsbl (%rax),%eax
cmp    $0x2f,%eax
je     11af <main+0x6f>
mov    0x2e4d(%rip),%rax
mov    (%rax),%edi
lea    0xe64(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1280 <main+0x140>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe84(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    11ea <main+0xaa>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rsi
lea    0xe6a(%rip),%rdi
mov    $0x0,%al
call   1030 <printx@plt>
mov    %eax,-0x4(%rbp)
jmp    1280 <main+0x140>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe60(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    125a <main+0x11a>
cmpl   $0x4,-0x8(%rbp)
je     1234 <main+0xf4>
mov    0x2dc8(%rip),%rax
mov    (%rax),%edi
lea    0xe3b(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1280 <main+0x140>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rsi
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdx
lea    0xe5f(%rip),%rdi
mov    $0x0,%al
call   1030 <printx@plt>
mov    %eax,-0x4(%rbp)
jmp    1280 <main+0x140>
mov    0x2d7f(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
lea    0xe56(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
cmp    $0x1,%edi
jg     1159 <main+0x19>
mov    (%rbx),%rdi
call   1060 <usage@plt>
jmp    11c2 <main+0x82>
mov    0x10(%rbx),%r14
cmpb   $0x2f,(%r14)
jne    11ab <main+0x6b>
mov    %edi,%ebp
mov    0x8(%rbx),%r15
lea    0xed2(%rip),%rsi
mov    %r15,%rdi
call   1040 <strcmp@plt>
test   %eax,%eax
je     11d2 <main+0x92>
lea    0xed6(%rip),%rsi
mov    %r15,%rdi
call   1040 <strcmp@plt>
test   %eax,%eax
je     11ed <main+0xad>
mov    0x2e4a(%rip),%rax
mov    (%rax),%edi
lea    0xf29(%rip),%rsi
mov    %r15,%rdx
xor    %eax,%eax
call   1050 <fprintf@plt>
jmp    11c2 <main+0x82>
mov    0x2e2e(%rip),%rax
mov    (%rax),%edi
lea    0xe45(%rip),%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    $0xffffffff,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xe6c(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <printx@plt>
cmp    $0x4,%ebp
jne    1211 <main+0xd1>
mov    0x18(%rbx),%rdx
lea    0xead(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <printx@plt>
mov    0x2dc8(%rip),%rax
mov    (%rax),%edi
lea    0xe3b(%rip),%rsi
jmp    11bb <main+0x7b>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [66 x i8] c"filename must begin with '/' as any sane URL! (e.g. /index.html)\0A\00"
@.str.1 = [3 x i8] c"-0\00"
@.str.2 = [20 x i8] c"GET %s HTTP/1.0\0D\0A\0D\0A\00"
@.str.3 = [3 x i8] c"-1\00"
@.str.4 = [78 x i8] c"missing <host>, required parameter for HTTP/1.1 header! (e.g. www.tty64.org)\0A\00"
@.str.5 = [30 x i8] c"GET %s HTTP/1.1\0D\0AHost: %s\0D\0A\0D\0A\00"
@.str.6 = [41 x i8] c"%s: unknown http protocol, try -0 or -1\0A\00"
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 slt i32 %6, 2
br i1 %7, label %8, label %13
8: ; preds = %2
%9 = load i8**, i8*** %5
%10 = getelementptr inbounds i8*, i8** %9, i64 0
%11 = load i8*, i8** %10
%12 = call i32 @usage(i8* %11)
store i32 -1, i32* %3
br label %61
13: ; preds = %2
%14 = load i8**, i8*** %5
%15 = getelementptr inbounds i8*, i8** %14, i64 2
%16 = load i8*, i8** %15
%17 = getelementptr inbounds i8, i8* %16, i64 0
%18 = load i8, i8* %17
%19 = sext i8 %18 to i32
%20 = icmp ne i32 %19, 47
br i1 %20, label %21, label %24
21: ; preds = %13
%22 = load i32, i32* @stderr
%23 = call i32 (i32, i8*, ...) @fprintf(i32 %22, i8* getelementptr inbounds ([66 x i8], [66 x i8]* @.str, i64 0, i64 0))
store i32 -1, i32* %3
br label %61
24: ; preds = %13
%25 = load i8**, i8*** %5
%26 = getelementptr inbounds i8*, i8** %25, i64 1
%27 = load i8*, i8** %26
%28 = call i32 @strcmp(i8* %27, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%29 = icmp ne i32 %28, 0
br i1 %29, label %35, label %30
30: ; preds = %24
%31 = load i8**, i8*** %5
%32 = getelementptr inbounds i8*, i8** %31, i64 2
%33 = load i8*, i8** %32
%34 = call i32 (i8*, i8*, ...) @printx(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), i8* %33)
store i32 %34, i32* %3
br label %61
35: ; preds = %24
%36 = load i8**, i8*** %5
%37 = getelementptr inbounds i8*, i8** %36, i64 1
%38 = load i8*, i8** %37
%39 = call i32 @strcmp(i8* %38, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%40 = icmp ne i32 %39, 0
br i1 %40, label %55, label %41
41: ; preds = %35
%42 = load i32, i32* %4
%43 = icmp ne i32 %42, 4
br i1 %43, label %44, label %47
44: ; preds = %41
%45 = load i32, i32* @stderr
%46 = call i32 (i32, i8*, ...) @fprintf(i32 %45, i8* getelementptr inbounds ([78 x i8], [78 x i8]* @.str.4, i64 0, i64 0))
store i32 -1, i32* %3
br label %61
47: ; preds = %41
%48 = load i8**, i8*** %5
%49 = getelementptr inbounds i8*, i8** %48, i64 2
%50 = load i8*, i8** %49
%51 = load i8**, i8*** %5
%52 = getelementptr inbounds i8*, i8** %51, i64 3
%53 = load i8*, i8** %52
%54 = call i32 (i8*, i8*, ...) @printx(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.5, i64 0, i64 0), i8* %50, i8* %53)
store i32 %54, i32* %3
br label %61
55: ; preds = %35
%56 = load i32, i32* @stderr
%57 = load i8**, i8*** %5
%58 = getelementptr inbounds i8*, i8** %57, i64 1
%59 = load i8*, i8** %58
%60 = call i32 (i32, i8*, ...) @fprintf(i32 %56, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.6, i64 0, i64 0), i8* %59)
store i32 -1, i32* %3
br label %61
61: ; preds = %55, %47, %44, %30, %21, %8
%62 = load i32, i32* %3
ret i32 %62
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [66 x i8] c"filename must begin with '/' as any sane URL! (e.g. /index.html)\0A\00"
@.str.1 = [3 x i8] c"-0\00"
@.str.2 = [20 x i8] c"GET %s HTTP/1.0\0D\0A\0D\0A\00"
@.str.3 = [3 x i8] c"-1\00"
@.str.4 = [78 x i8] c"missing <host>, required parameter for HTTP/1.1 header! (e.g. www.tty64.org)\0A\00"
@.str.5 = [30 x i8] c"GET %s HTTP/1.1\0D\0AHost: %s\0D\0A\0D\0A\00"
@.str.6 = [41 x i8] c"%s: unknown http protocol, try -0 or -1\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp slt i32 %0, 2
br i1 %3, label %4, label %7
4: ; preds = %2
%5 = load i8*, i8** %1
%6 = tail call i32 @usage(i8* %5)
br label %37
7: ; preds = %2
%8 = getelementptr inbounds i8*, i8** %1, i64 2
%9 = load i8*, i8** %8
%10 = load i8, i8* %9
%11 = icmp eq i8 %10, 47
br i1 %11, label %15, label %12
12: ; preds = %7
%13 = load i32, i32* @stderr
%14 = tail call i32 (i32, i8*, ...) @fprintf(i32 %13, i8* getelementptr inbounds ([66 x i8], [66 x i8]* @.str, i64 0, i64 0))
br label %37
15: ; preds = %7
%16 = getelementptr inbounds i8*, i8** %1, i64 1
%17 = load i8*, i8** %16
%18 = tail call i32 @strcmp(i8* dereferenceable(1) %17, i8* dereferenceable(3) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%19 = icmp eq i32 %18, 0
br i1 %19, label %20, label %22
20: ; preds = %15
%21 = tail call i32 (i8*, i8*, ...) @printx(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), i8* %9)
br label %37
22: ; preds = %15
%23 = tail call i32 @strcmp(i8* dereferenceable(1) %17, i8* dereferenceable(3) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%24 = icmp eq i32 %23, 0
br i1 %24, label %25, label %34
25: ; preds = %22
%26 = icmp eq i32 %0, 4
br i1 %26, label %30, label %27
27: ; preds = %25
%28 = load i32, i32* @stderr
%29 = tail call i32 (i32, i8*, ...) @fprintf(i32 %28, i8* getelementptr inbounds ([78 x i8], [78 x i8]* @.str.4, i64 0, i64 0))
br label %37
30: ; preds = %25
%31 = getelementptr inbounds i8*, i8** %1, i64 3
%32 = load i8*, i8** %31
%33 = tail call i32 (i8*, i8*, ...) @printx(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.5, i64 0, i64 0), i8* %9, i8* %32)
br label %37
34: ; preds = %22
%35 = load i32, i32* @stderr
%36 = tail call i32 (i32, i8*, ...) @fprintf(i32 %35, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.6, i64 0, i64 0), i8* %17)
br label %37
37: ; preds = %34, %30, %27, %20, %12, %4
%38 = phi i32 [ -1, %4 ], [ -1, %12 ], [ -1, %34 ], [ -1, %27 ], [ %33, %30 ], [ %21, %20 ]
ret i32 %38
}