#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*/ exit(int);
int /*<<< orphan*/ objclose();
int /*<<< orphan*/ objcountvals();
int /*<<< orphan*/ objgenfaces();
int /*<<< orphan*/ objgenverts();
int /*<<< orphan*/ objinit(char *);
int /*<<< orphan*/ objpopulate();
int /*<<< orphan*/ objwritecmb();
int /*<<< orphan*/ printf(char *, char *);
int strlen(char *);
int /*<<< orphan*/ usage(char *);
int main(int argc, char **argv) {
  if (argc < 2)
    usage(argv[0]);
  int i = strlen(argv[1]);
  unsigned int *tmp = (unsigned int *)&argv[1][i - 4];
  if (*tmp != ('.' | 'o' << 8 | 'b' << 16 | 'j' << 24)) {
    printf("%s is not an obj file\n", argv[1]);
    exit(-1);
  }
  objinit(argv[1]);
  objcountvals();
  objpopulate();
  objgenverts();
  objgenfaces();
  objwritecmb();
  objclose();
  return 0;
}


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   $0x2,-0x8(%rbp)
jge    11dc <main+0x2c>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   10b0 <usage@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1050 <strlen@plt>
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    -0x14(%rbp),%ecx
sub    $0x4,%ecx
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
cmpl   $0x6a626f2e,(%rax)
je     1232 <main+0x82>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xddd(%rip),%rdi
call   1060 <printf@plt>
mov    $0xffffffff,%edi
call   10d0 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1090 <objinit@plt>
mov    $0x0,%al
call   10c0 <objcountvals@plt>
mov    $0x0,%al
call   10a0 <objpopulate@plt>
mov    $0x0,%al
call   1040 <objgenverts@plt>
mov    $0x0,%al
call   1080 <objgenfaces@plt>
mov    $0x0,%al
call   1070 <objwritecmb@plt>
mov    $0x0,%al
call   1030 <objclose@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
mov    %rsi,%rbx
cmp    $0x1,%edi
jg     11c1 <main+0x11>
mov    (%rbx),%rdi
call   10b0 <usage@plt>
mov    0x8(%rbx),%rdi
call   1050 <strlen@plt>
mov    0x8(%rbx),%rsi
cltq
cmpl   $0x6a626f2e,-0x4(%rax,%rsi,1)
6a
jne    1210 <main+0x60>
mov    %rsi,%rdi
call   1090 <objinit@plt>
xor    %eax,%eax
call   10c0 <objcountvals@plt>
xor    %eax,%eax
call   10a0 <objpopulate@plt>
xor    %eax,%eax
call   1040 <objgenverts@plt>
xor    %eax,%eax
call   1080 <objgenfaces@plt>
xor    %eax,%eax
call   1070 <objwritecmb@plt>
xor    %eax,%eax
call   1030 <objclose@plt>
xor    %eax,%eax
pop    %rbx
ret
lea    0xde9(%rip),%rdi
call   1060 <printf@plt>
mov    $0xffffffff,%edi
call   10d0 <exit@plt>

LLVM IR (-O0):
@.str = [23 x i8] c"%s is not an obj file\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%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 slt 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 0
%13 = load i8*, i8** %12
%14 = call i32 @usage(i8* %13)
br label %15
15: ; preds = %10, %2
%16 = load i8**, i8*** %5
%17 = getelementptr inbounds i8*, i8** %16, i64 1
%18 = load i8*, i8** %17
%19 = call i32 @strlen(i8* %18)
store i32 %19, i32* %6
%20 = load i8**, i8*** %5
%21 = getelementptr inbounds i8*, i8** %20, i64 1
%22 = load i8*, i8** %21
%23 = load i32, i32* %6
%24 = sub nsw i32 %23, 4
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds i8, i8* %22, i64 %25
%27 = bitcast i8* %26 to i32*
store i32* %27, i32** %7
%28 = load i32*, i32** %7
%29 = load i32, i32* %28
%30 = icmp ne i32 %29, 1784835886
br i1 %30, label %31, label %37
31: ; preds = %15
%32 = load i8**, i8*** %5
%33 = getelementptr inbounds i8*, i8** %32, i64 1
%34 = load i8*, i8** %33
%35 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i8* %34)
%36 = call i32 @exit(i32 -1)
unreachable
37: ; preds = %15
%38 = load i8**, i8*** %5
%39 = getelementptr inbounds i8*, i8** %38, i64 1
%40 = load i8*, i8** %39
%41 = call i32 @objinit(i8* %40)
%42 = call i32 (...) @objcountvals()
%43 = call i32 (...) @objpopulate()
%44 = call i32 (...) @objgenverts()
%45 = call i32 (...) @objgenfaces()
%46 = call i32 (...) @objwritecmb()
%47 = call i32 (...) @objclose()
ret i32 0
}

LLVM IR (-O2):
@.str = [23 x i8] c"%s is not an obj file\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 %7
7: ; preds = %4, %2
%8 = getelementptr inbounds i8*, i8** %1, i64 1
%9 = load i8*, i8** %8
%10 = tail call i32 @strlen(i8* %9)
%11 = load i8*, i8** %8
%12 = add nsw i32 %10, -4
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds i8, i8* %11, i64 %13
%15 = bitcast i8* %14 to i32*
%16 = load i32, i32* %15
%17 = icmp eq i32 %16, 1784835886
br i1 %17, label %21, label %18
18: ; preds = %7
%19 = tail call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i8* %11)
%20 = tail call i32 @exit(i32 -1)
unreachable
21: ; preds = %7
%22 = tail call i32 @objinit(i8* %11)
%23 = tail call i32 (...) @objcountvals()
%24 = tail call i32 (...) @objpopulate()
%25 = tail call i32 (...) @objgenverts()
%26 = tail call i32 (...) @objgenfaces()
%27 = tail call i32 (...) @objwritecmb()
%28 = tail call i32 (...) @objclose()
ret i32 0
}