#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*/ FILE;

/* Variables and functions */
int EXIT_SUCCESS;
int atoi(char *);
int /*<<< orphan*/ fatal(char *, ...);
int /*<<< orphan*/ output_close(int /*<<< orphan*/ **, int);
int /*<<< orphan*/ **output_open(char *, int);
int /*<<< orphan*/ split(int /*<<< orphan*/ **, int);
scalar_t__ strlen(char *);
int /*<<< orphan*/ usage();
int main(int argc, char *argv[]) {
  int output_ct;
  FILE **out;
  if (argc != 3)
    usage();
  output_ct = atoi(argv[1]);
  if (output_ct < 1)
    fatal("invalid number of output files: %d", output_ct);
  if (strlen(argv[2]) == 0)
    fatal("length of BASENAME cannot be 0");
  out = output_open(argv[2], output_ct);
  split(out, output_ct);
  output_close(out, output_ct);
  return EXIT_SUCCESS;
}


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   $0x3,-0x8(%rbp)
je     1197 <main+0x27>
mov    $0x0,%al
call   1070 <usage@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1080 <atoi@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x1,-0x14(%rbp)
jge    11c2 <main+0x52>
mov    -0x14(%rbp),%esi
lea    0xe45(%rip),%rdi
mov    $0x0,%al
call   1090 <fatal@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1030 <strlen@plt>
cmp    $0x0,%rax
jne    11e7 <main+0x77>
lea    0xe43(%rip),%rdi
mov    $0x0,%al
call   1090 <fatal@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
mov    -0x14(%rbp),%esi
call   1060 <output_open@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1050 <split@plt>
mov    -0x20(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1040 <output_close@plt>
mov    0x2dc6(%rip),%rax
mov    (%rax),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
mov    %rsi,%rbx
cmp    $0x3,%edi
je     1172 <main+0x12>
xor    %eax,%eax
call   1060 <usage@plt>
mov    0x8(%rbx),%rdi
call   1070 <atoi@plt>
mov    %eax,%ebp
test   %eax,%eax
jg     1191 <main+0x31>
lea    0xe78(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1080 <fatal@plt>
mov    0x10(%rbx),%rdi
cmpb   $0x0,(%rdi)
jne    11ac <main+0x4c>
lea    0xe82(%rip),%rdi
xor    %eax,%eax
call   1080 <fatal@plt>
mov    0x10(%rbx),%rdi
mov    %ebp,%esi
call   1050 <output_open@plt>
mov    %rax,%rbx
mov    %rax,%rdi
mov    %ebp,%esi
call   1040 <split@plt>
mov    %rbx,%rdi
mov    %ebp,%esi
call   1030 <output_close@plt>
mov    0x2e0f(%rip),%rax
mov    (%rax),%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [35 x i8] c"invalid number of output files: %d\00"
@.str.1 = [31 x i8] c"length of BASENAME cannot be 0\00"
@EXIT_SUCCESS = global i32 0
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 ne i32 %8, 3
br i1 %9, label %10, label %12
10: ; preds = %2
%11 = call i32 (...) @usage()
br label %12
12: ; preds = %10, %2
%13 = load i8**, i8*** %5
%14 = getelementptr inbounds i8*, i8** %13, i64 1
%15 = load i8*, i8** %14
%16 = call i32 @atoi(i8* %15)
store i32 %16, i32* %6
%17 = load i32, i32* %6
%18 = icmp slt i32 %17, 1
br i1 %18, label %19, label %22
19: ; preds = %12
%20 = load i32, i32* %6
%21 = call i32 (i8*, ...) @fatal(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0), i32 %20)
br label %22
22: ; preds = %19, %12
%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 = icmp eq i64 %26, 0
br i1 %27, label %28, label %30
28: ; preds = %22
%29 = call i32 (i8*, ...) @fatal(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0))
br label %30
30: ; preds = %28, %22
%31 = load i8**, i8*** %5
%32 = getelementptr inbounds i8*, i8** %31, i64 2
%33 = load i8*, i8** %32
%34 = load i32, i32* %6
%35 = call i32** @output_open(i8* %33, i32 %34)
store i32** %35, i32*** %7
%36 = load i32**, i32*** %7
%37 = load i32, i32* %6
%38 = call i32 @split(i32** %36, i32 %37)
%39 = load i32**, i32*** %7
%40 = load i32, i32* %6
%41 = call i32 @output_close(i32** %39, i32 %40)
%42 = load i32, i32* @EXIT_SUCCESS
ret i32 %42
}

LLVM IR (-O2):
@.str = [35 x i8] c"invalid number of output files: %d\00"
@.str.1 = [31 x i8] c"length of BASENAME cannot be 0\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 3
br i1 %3, label %6, label %4
4: ; preds = %2
%5 = tail call i32 (...) @usage()
br label %6
6: ; preds = %4, %2
%7 = getelementptr inbounds i8*, i8** %1, i64 1
%8 = load i8*, i8** %7
%9 = tail call i32 @atoi(i8* %8)
%10 = icmp slt i32 %9, 1
br i1 %10, label %11, label %13
11: ; preds = %6
%12 = tail call i32 (i8*, ...) @fatal(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0), i32 %9)
br label %13
13: ; preds = %11, %6
%14 = getelementptr inbounds i8*, i8** %1, i64 2
%15 = load i8*, i8** %14
%16 = load i8, i8* %15
%17 = icmp eq i8 %16, 0
br i1 %17, label %18, label %21
18: ; preds = %13
%19 = tail call i32 (i8*, ...) @fatal(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0))
%20 = load i8*, i8** %14
br label %21
21: ; preds = %18, %13
%22 = phi i8* [ %20, %18 ], [ %15, %13 ]
%23 = tail call i32** @output_open(i8* %22, i32 %9)
%24 = tail call i32 @split(i32** %23, i32 %9)
%25 = tail call i32 @output_close(i32** %23, i32 %9)
%26 = load i32, i32* @EXIT_SUCCESS
ret i32 %26
}