#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*/ PutIndent(int);
int getchar();
int /*<<< orphan*/ printf(char *, char *, ...);
int PutConsolidatedCode(int opcode, int indent, char *instructions,
                        char *instructionm) {
  int c;
  int n = 1;
  c = getchar();
  while (c == opcode || c == 10 || c == 13) {
    if (c == opcode)
      ++n;
    c = getchar();
  }
  PutIndent(indent);
  if (n == 1)
    printf("%s;\n", instructions);
  else
    printf("%s%d;\n", instructionm, n);
  return c;
}


x86 assembly (clang, -O0):
<PutConsolidatedCode>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
mov    %rcx,-0x18(%rbp)
movl   $0x1,-0x20(%rbp)
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%ecx
mov    $0x1,%al
cmp    -0x4(%rbp),%ecx
mov    %al,-0x21(%rbp)
je     1181 <PutConsolidatedCode+0x51>
mov    $0x1,%al
cmpl   $0xa,-0x1c(%rbp)
mov    %al,-0x21(%rbp)
je     1181 <PutConsolidatedCode+0x51>
cmpl   $0xd,-0x1c(%rbp)
sete   %al
mov    %al,-0x21(%rbp)
mov    -0x21(%rbp),%al
test   $0x1,%al
jne    1191 <PutConsolidatedCode+0x61>
jmp    11b5 <PutConsolidatedCode+0x85>
mov    -0x1c(%rbp),%eax
cmp    -0x4(%rbp),%eax
jne    11a6 <PutConsolidatedCode+0x76>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %eax,-0x1c(%rbp)
jmp    1157 <PutConsolidatedCode+0x27>
mov    -0x8(%rbp),%edi
call   1050 <PutIndent@plt>
cmpl   $0x1,-0x20(%rbp)
jne    11de <PutConsolidatedCode+0xae>
mov    -0x10(%rbp),%rsi
lea    0xe2e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11f3 <PutConsolidatedCode+0xc3>
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%edx
lea    0xe19(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x1c(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<PutConsolidatedCode>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rcx,%r14
mov    %rdx,%r15
mov    %esi,%r12d
mov    %edi,%ebp
mov    $0x1,%r13d
jmp    115a <PutConsolidatedCode+0x2a>
xchg   %ax,%ax
xor    %eax,%eax
cmp    %ebp,%ebx
sete   %al
add    %eax,%r13d
xor    %eax,%eax
call   1040 <getchar@plt>
mov    %eax,%ebx
cmp    %ebp,%eax
je     1150 <PutConsolidatedCode+0x20>
cmp    $0xd,%ebx
je     1150 <PutConsolidatedCode+0x20>
cmp    $0xa,%ebx
je     1150 <PutConsolidatedCode+0x20>
mov    %r12d,%edi
call   1050 <PutIndent@plt>
cmp    $0x1,%r13d
jne    1192 <PutConsolidatedCode+0x62>
lea    0xe7a(%rip),%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1030 <printf@plt>
jmp    11a6 <PutConsolidatedCode+0x76>
lea    0xe6c(%rip),%rdi
mov    %r14,%rsi
mov    %r13d,%edx
xor    %eax,%eax
call   1030 <printf@plt>
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [5 x i8] c"%s;\0A\00"
@.str.1 = [7 x i8] c"%s%d;\0A\00"
define i32 @PutConsolidatedCode(i32 %0, i32 %1, i8* %2, i8* %3) {
%5 = alloca i32
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i32
store i32 %0, i32* %5
store i32 %1, i32* %6
store i8* %2, i8** %7
store i8* %3, i8** %8
store i32 1, i32* %10
%11 = call i32 (...) @getchar()
store i32 %11, i32* %9
br label %12
12: ; preds = %31, %4
%13 = load i32, i32* %9
%14 = load i32, i32* %5
%15 = icmp eq i32 %13, %14
br i1 %15, label %22, label %16
16: ; preds = %12
%17 = load i32, i32* %9
%18 = icmp eq i32 %17, 10
br i1 %18, label %22, label %19
19: ; preds = %16
%20 = load i32, i32* %9
%21 = icmp eq i32 %20, 13
br label %22
22: ; preds = %19, %16, %12
%23 = phi i1 [ true, %16 ], [ true, %12 ], [ %21, %19 ]
br i1 %23, label %24, label %33
24: ; preds = %22
%25 = load i32, i32* %9
%26 = load i32, i32* %5
%27 = icmp eq i32 %25, %26
br i1 %27, label %28, label %31
28: ; preds = %24
%29 = load i32, i32* %10
%30 = add nsw i32 %29, 1
store i32 %30, i32* %10
br label %31
31: ; preds = %28, %24
%32 = call i32 (...) @getchar()
store i32 %32, i32* %9
br label %12
33: ; preds = %22
%34 = load i32, i32* %6
%35 = call i32 @PutIndent(i32 %34)
%36 = load i32, i32* %10
%37 = icmp eq i32 %36, 1
br i1 %37, label %38, label %41
38: ; preds = %33
%39 = load i8*, i8** %7
%40 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %39)
br label %45
41: ; preds = %33
%42 = load i8*, i8** %8
%43 = load i32, i32* %10
%44 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8* %42, i32 %43)
br label %45
45: ; preds = %41, %38
%46 = load i32, i32* %9
ret i32 %46
}

LLVM IR (-O2):
@.str = [5 x i8] c"%s;\0A\00"
@.str.1 = [7 x i8] c"%s%d;\0A\00"
define i32 @PutConsolidatedCode(i32 %0, i32 %1, i8* %2, i8* %3) {
br label %5
5: ; preds = %10, %4
%6 = phi i32 [ 1, %4 ], [ %12, %10 ]
%7 = tail call i32 (...) @getchar()
%8 = icmp eq i32 %7, %0
br i1 %8, label %10, label %9
9: ; preds = %5
switch i32 %7, label %13 [
i32 13, label %10
i32 10, label %10
]
10: ; preds = %9, %9, %5
%11 = zext i1 %8 to i32
%12 = add nuw nsw i32 %6, %11
br label %5
13: ; preds = %9
%14 = tail call i32 @PutIndent(i32 %1)
%15 = icmp eq i32 %6, 1
br i1 %15, label %16, label %18
16: ; preds = %13
%17 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %2)
br label %20
18: ; preds = %13
%19 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8* %3, i32 %6)
br label %20
20: ; preds = %18, %16
ret i32 %7
}