#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 atoi(char *);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
char *joinlines(char *, int);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ stderr;
int main(int argc, char **argv) {
  int group_count;
  char *results;
  if (argc < 2) {
    fprintf(stderr, "Usage: %s delimiter [group_count]\n", argv[0]);
    exit(1);
  }
  if (argc == 3)
    group_count = atoi(argv[2]);
  else
    group_count = 0;
  while (1) {
    if (!(results = joinlines(argv[1], group_count)))
      break;
    printf("%s\n", results);
  }
  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    1196 <main+0x46>
mov    0x2e69(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe79(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
cmpl   $0x3,-0x8(%rbp)
jne    11b5 <main+0x65>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1050 <atoi@plt>
mov    %eax,-0x14(%rbp)
jmp    11bc <main+0x6c>
movl   $0x0,-0x14(%rbp)
jmp    11c1 <main+0x71>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    -0x14(%rbp),%esi
call   1060 <joinlines@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
jne    11e4 <main+0x94>
jmp    11f9 <main+0xa9>
mov    -0x20(%rbp),%rsi
lea    0xe34(%rip),%rdi
call   1030 <printf@plt>
jmp    11c1 <main+0x71>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%rbx
cmp    $0x1,%edi
jle    11b2 <main+0x62>
xor    %ebp,%ebp
cmp    $0x3,%edi
jne    116e <main+0x1e>
mov    0x10(%rbx),%rdi
call   1050 <atoi@plt>
mov    %eax,%ebp
mov    0x8(%rbx),%rdi
mov    %ebp,%esi
call   1060 <joinlines@plt>
test   %rax,%rax
je     11ab <main+0x5b>
lea    0xe9e(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
nop
mov    %r14,%rdi
mov    %rax,%rsi
call   1030 <printf@plt>
mov    0x8(%rbx),%rdi
mov    %ebp,%esi
call   1060 <joinlines@plt>
test   %rax,%rax
jne    1190 <main+0x40>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret
mov    0x2e27(%rip),%rax
mov    (%rax),%edi
mov    (%rbx),%rdx
lea    0xe3b(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [35 x i8] c"Usage: %s delimiter [group_count]\0A\00"
@.str.1 = [4 x i8] c"%s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i8*
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 %17
10: ; preds = %2
%11 = load i32, i32* @stderr
%12 = load i8**, i8*** %5
%13 = getelementptr inbounds i8*, i8** %12, i64 0
%14 = load i8*, i8** %13
%15 = call i32 @fprintf(i32 %11, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0), i8* %14)
%16 = call i32 @exit(i32 1)
unreachable
17: ; preds = %2
%18 = load i32, i32* %4
%19 = icmp eq i32 %18, 3
br i1 %19, label %20, label %25
20: ; preds = %17
%21 = load i8**, i8*** %5
%22 = getelementptr inbounds i8*, i8** %21, i64 2
%23 = load i8*, i8** %22
%24 = call i32 @atoi(i8* %23)
store i32 %24, i32* %6
br label %26
25: ; preds = %17
store i32 0, i32* %6
br label %26
26: ; preds = %25, %20
br label %27
27: ; preds = %26, %35
%28 = load i8**, i8*** %5
%29 = getelementptr inbounds i8*, i8** %28, i64 1
%30 = load i8*, i8** %29
%31 = load i32, i32* %6
%32 = call i8* @joinlines(i8* %30, i32 %31)
store i8* %32, i8** %7
%33 = icmp ne i8* %32, null
br i1 %33, label %35, label %34
34: ; preds = %27
br label %38
35: ; preds = %27
%36 = load i8*, i8** %7
%37 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %36)
br label %27
38: ; preds = %34
ret i32 0
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [35 x i8] c"Usage: %s delimiter [group_count]\0A\00"
@.str.1 = [4 x i8] c"%s\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp slt i32 %0, 2
br i1 %3, label %4, label %9
4: ; preds = %2
%5 = load i32, i32* @stderr
%6 = load i8*, i8** %1
%7 = tail call i32 @fprintf(i32 %5, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0), i8* %6)
%8 = tail call i32 @exit(i32 1)
unreachable
9: ; preds = %2
%10 = icmp eq i32 %0, 3
br i1 %10, label %11, label %15
11: ; preds = %9
%12 = getelementptr inbounds i8*, i8** %1, i64 2
%13 = load i8*, i8** %12
%14 = tail call i32 @atoi(i8* %13)
br label %15
15: ; preds = %9, %11
%16 = phi i32 [ %14, %11 ], [ 0, %9 ]
%17 = getelementptr inbounds i8*, i8** %1, i64 1
%18 = load i8*, i8** %17
%19 = tail call i8* @joinlines(i8* %18, i32 %16)
%20 = icmp eq i8* %19, null
br i1 %20, label %27, label %21
21: ; preds = %15, %21
%22 = phi i8* [ %25, %21 ], [ %19, %15 ]
%23 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %22)
%24 = load i8*, i8** %17
%25 = tail call i8* @joinlines(i8* %24, i32 %16)
%26 = icmp eq i8* %25, null
br i1 %26, label %27, label %21
27: ; preds = %21, %15
ret i32 0
}