#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 */
scalar_t__ isspace(char);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ putchar(char);
void emit_match(const char *str, int pos) {
  printf("\t%s", str);
  printf("\t");
  while (pos-- > 0) {
    char c = *str++;
    putchar(isspace(c) ? c : ' ');
  }
  printf("^\n");
}


x86 assembly (clang, -O0):
<emit_match>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%rsi
lea    0xeb6(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xeac(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0xc(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0xc(%rbp)
cmp    $0x0,%eax
jle    11c3 <emit_match+0x93>
mov    -0x8(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x8(%rbp)
mov    (%rax),%al
mov    %al,-0xd(%rbp)
movsbl -0xd(%rbp),%edi
call   1050 <isspace@plt>
cmp    $0x0,%rax
je     11a6 <emit_match+0x76>
movsbl -0xd(%rbp),%eax
mov    %eax,-0x14(%rbp)
jmp    11b3 <emit_match+0x83>
mov    $0x20,%eax
mov    %eax,-0x14(%rbp)
jmp    11b3 <emit_match+0x83>
mov    -0x14(%rbp),%eax
movsbl %al,%edi
call   1030 <putchar@plt>
jmp    115f <emit_match+0x2f>
lea    0xe3c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<emit_match>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %esi,%r14d
mov    %rdi,%rbx
lea    0xeac(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0x9,%edi
call   1030 <putchar@plt>
test   %r14d,%r14d
jle    11a6 <emit_match+0x66>
add    $0x1,%r14d
mov    $0x20,%r15d
nopw   0x0(%rax,%rax,1)
movsbl (%rbx),%ebp
add    $0x1,%rbx
mov    %ebp,%edi
call   1060 <isspace@plt>
test   %rax,%rax
cmove  %r15d,%ebp
mov    %ebp,%edi
call   1030 <putchar@plt>
add    $0xffffffff,%r14d
cmp    $0x1,%r14d
ja     1180 <emit_match+0x40>
lea    0xe57(%rip),%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <puts@plt>

LLVM IR (-O0):
@.str = [4 x i8] c"\09%s\00"
@.str.1 = [2 x i8] c"\09\00"
@.str.2 = [3 x i8] c"^\0A\00"
define void @emit_match(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i8
store i8* %0, i8** %3
store i32 %1, i32* %4
%6 = load i8*, i8** %3
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %6)
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %9
9: ; preds = %24, %2
%10 = load i32, i32* %4
%11 = add nsw i32 %10, -1
store i32 %11, i32* %4
%12 = icmp sgt i32 %10, 0
br i1 %12, label %13, label %28
13: ; preds = %9
%14 = load i8*, i8** %3
%15 = getelementptr inbounds i8, i8* %14, i32 1
store i8* %15, i8** %3
%16 = load i8, i8* %14
store i8 %16, i8* %5
%17 = load i8, i8* %5
%18 = call i64 @isspace(i8 signext %17)
%19 = icmp ne i64 %18, 0
br i1 %19, label %20, label %23
20: ; preds = %13
%21 = load i8, i8* %5
%22 = sext i8 %21 to i32
br label %24
23: ; preds = %13
br label %24
24: ; preds = %23, %20
%25 = phi i32 [ %22, %20 ], [ 32, %23 ]
%26 = trunc i32 %25 to i8
%27 = call i32 @putchar(i8 signext %26)
br label %9
28: ; preds = %9
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [4 x i8] c"\09%s\00"
@str = [2 x i8] c"^\00"
define void @emit_match(i8* %0, i32 %1) {
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %0)
%4 = tail call i32 bitcast (i32 (i8)* @putchar to i32 (i32)*)(i32 9)
%5 = icmp sgt i32 %1, 0
br i1 %5, label %6, label %17
6: ; preds = %2, %6
%7 = phi i8* [ %10, %6 ], [ %0, %2 ]
%8 = phi i32 [ %9, %6 ], [ %1, %2 ]
%9 = add nsw i32 %8, -1
%10 = getelementptr inbounds i8, i8* %7, i64 1
%11 = load i8, i8* %7
%12 = tail call i64 @isspace(i8 signext %11)
%13 = icmp eq i64 %12, 0
%14 = select i1 %13, i8 32, i8 %11
%15 = tail call i32 @putchar(i8 signext %14)
%16 = icmp ugt i32 %8, 1
br i1 %16, label %6, label %17
17: ; preds = %6, %2
%18 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str, i64 0, i64 0))
ret void
}