#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 EXIT_FAILURE;
int atoi(char *);
char *duo_split_at(char *, char, int);
int failure();
int /*<<< orphan*/ printf(char *, char *);
scalar_t__ strcmp(char *, char *);
int success();
int main(int argc, char *argv[]) {
  if (argc != 5) {
    printf("Format: %s <string|NULL> <delimiter> <position> <expected|NULL>\n",
           argv[0]);
    return EXIT_FAILURE;
  }
  char *s = argv[1];
  char *delimiter = argv[2];
  int position = atoi(argv[3]);
  char *expected = argv[4];
  if (strcmp(s, "NULL") == 0) {
    s = NULL;
  }
  char *result = duo_split_at(s, *delimiter, position);
  if ((result == NULL && strcmp(expected, "NULL") == 0) ||
      (result != NULL && strcmp(result, expected) == 0)) {
    return success();
  }
  return failure();
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x5,-0x8(%rbp)
je     11a4 <main+0x44>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe72(%rip),%rdi
call   1050 <printf@plt>
mov    0x2e46(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    1273 <main+0x113>
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   1080 <atoi@plt>
mov    %eax,-0x24(%rbp)
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rax
mov    %rax,-0x30(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xe5e(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
jne    11fa <main+0x9a>
movq   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rax
mov    (%rax),%al
mov    -0x24(%rbp),%edx
movsbl %al,%esi
call   1030 <duo_split_at@plt>
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x38(%rbp)
jne    1238 <main+0xd8>
mov    -0x30(%rbp),%rdi
lea    0xe18(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
je     125a <main+0xfa>
cmpq   $0x0,-0x38(%rbp)
je     1269 <main+0x109>
mov    -0x38(%rbp),%rdi
mov    -0x30(%rbp),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
jne    1269 <main+0x109>
mov    $0x0,%al
call   1040 <success@plt>
mov    %eax,-0x4(%rbp)
jmp    1273 <main+0x113>
mov    $0x0,%al
call   1060 <failure@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
cmp    $0x5,%edi
jne    11b7 <main+0x57>
mov    0x8(%rbx),%r14
mov    0x10(%rbx),%r15
mov    0x18(%rbx),%rdi
call   1080 <atoi@plt>
mov    %eax,%ebp
mov    0x20(%rbx),%rbx
lea    0xeb4(%rip),%rsi
mov    %r14,%rdi
call   1070 <strcmp@plt>
test   %rax,%rax
cmove  %rax,%r14
movsbl (%r15),%esi
mov    %r14,%rdi
mov    %ebp,%edx
call   1030 <duo_split_at@plt>
test   %rax,%rax
je     11da <main+0x7a>
mov    %rax,%rdi
mov    %rbx,%rsi
jmp    11e4 <main+0x84>
mov    (%rbx),%rsi
lea    0xe3f(%rip),%rdi
call   1050 <printf@plt>
mov    0x2e13(%rip),%rax
mov    (%rax),%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xe60(%rip),%rsi
mov    %rbx,%rdi
call   1070 <strcmp@plt>
test   %rax,%rax
je     11ff <main+0x9f>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1060 <failure@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <success@plt>

LLVM IR (-O0):
@.str = [65 x i8] c"Format: %s <string|NULL> <delimiter> <position> <expected|NULL>\0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [5 x i8] c"NULL\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
%9 = alloca i8*
%10 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%11 = load i32, i32* %4
%12 = icmp ne i32 %11, 5
br i1 %12, label %13, label %19
13: ; preds = %2
%14 = load i8**, i8*** %5
%15 = getelementptr inbounds i8*, i8** %14, i64 0
%16 = load i8*, i8** %15
%17 = call i32 @printf(i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str, i64 0, i64 0), i8* %16)
%18 = load i32, i32* @EXIT_FAILURE
store i32 %18, i32* %3
br label %61
19: ; preds = %2
%20 = load i8**, i8*** %5
%21 = getelementptr inbounds i8*, i8** %20, i64 1
%22 = load i8*, i8** %21
store i8* %22, i8** %6
%23 = load i8**, i8*** %5
%24 = getelementptr inbounds i8*, i8** %23, i64 2
%25 = load i8*, i8** %24
store i8* %25, i8** %7
%26 = load i8**, i8*** %5
%27 = getelementptr inbounds i8*, i8** %26, i64 3
%28 = load i8*, i8** %27
%29 = call i32 @atoi(i8* %28)
store i32 %29, i32* %8
%30 = load i8**, i8*** %5
%31 = getelementptr inbounds i8*, i8** %30, i64 4
%32 = load i8*, i8** %31
store i8* %32, i8** %9
%33 = load i8*, i8** %6
%34 = call i64 @strcmp(i8* %33, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%35 = icmp eq i64 %34, 0
br i1 %35, label %36, label %37
36: ; preds = %19
store i8* null, i8** %6
br label %37
37: ; preds = %36, %19
%38 = load i8*, i8** %6
%39 = load i8*, i8** %7
%40 = load i8, i8* %39
%41 = load i32, i32* %8
%42 = call i8* @duo_split_at(i8* %38, i8 signext %40, i32 %41)
store i8* %42, i8** %10
%43 = load i8*, i8** %10
%44 = icmp eq i8* %43, null
br i1 %44, label %45, label %49
45: ; preds = %37
%46 = load i8*, i8** %9
%47 = call i64 @strcmp(i8* %46, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%48 = icmp eq i64 %47, 0
br i1 %48, label %57, label %49
49: ; preds = %45, %37
%50 = load i8*, i8** %10
%51 = icmp ne i8* %50, null
br i1 %51, label %52, label %59
52: ; preds = %49
%53 = load i8*, i8** %10
%54 = load i8*, i8** %9
%55 = call i64 @strcmp(i8* %53, i8* %54)
%56 = icmp eq i64 %55, 0
br i1 %56, label %57, label %59
57: ; preds = %52, %45
%58 = call i32 (...) @success()
store i32 %58, i32* %3
br label %61
59: ; preds = %52, %49
%60 = call i32 (...) @failure()
store i32 %60, i32* %3
br label %61
61: ; preds = %59, %57, %13
%62 = load i32, i32* %3
ret i32 %62
}

LLVM IR (-O2):
@.str = [65 x i8] c"Format: %s <string|NULL> <delimiter> <position> <expected|NULL>\0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [5 x i8] c"NULL\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 5
br i1 %3, label %8, label %4
4: ; preds = %2
%5 = load i8*, i8** %1
%6 = tail call i32 @printf(i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str, i64 0, i64 0), i8* %5)
%7 = load i32, i32* @EXIT_FAILURE
br label %34
8: ; preds = %2
%9 = getelementptr inbounds i8*, i8** %1, i64 1
%10 = load i8*, i8** %9
%11 = getelementptr inbounds i8*, i8** %1, i64 2
%12 = load i8*, i8** %11
%13 = getelementptr inbounds i8*, i8** %1, i64 3
%14 = load i8*, i8** %13
%15 = tail call i32 @atoi(i8* %14)
%16 = getelementptr inbounds i8*, i8** %1, i64 4
%17 = load i8*, i8** %16
%18 = tail call i64 @strcmp(i8* %10, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%19 = icmp eq i64 %18, 0
%20 = select i1 %19, i8* null, i8* %10
%21 = load i8, i8* %12
%22 = tail call i8* @duo_split_at(i8* %20, i8 signext %21, i32 %15)
%23 = icmp eq i8* %22, null
br i1 %23, label %24, label %27
24: ; preds = %8
%25 = tail call i64 @strcmp(i8* %17, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%26 = icmp eq i64 %25, 0
br i1 %26, label %30, label %32
27: ; preds = %8
%28 = tail call i64 @strcmp(i8* %22, i8* %17)
%29 = icmp eq i64 %28, 0
br i1 %29, label %30, label %32
30: ; preds = %27, %24
%31 = tail call i32 (...) @success()
br label %34
32: ; preds = %24, %27
%33 = tail call i32 (...) @failure()
br label %34
34: ; preds = %30, %32, %4
%35 = phi i32 [ %7, %4 ], [ %31, %30 ], [ %33, %32 ]
ret i32 %35
}