#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 /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
void output_tag(FILE *fp, char *p) {
  int i = 0;
  while (i < 4 && p && *p) {
    fprintf(fp, "%c", *p);
    i++;
    p++;
  }
  for (; i < 4; ++i)
    fprintf(fp, " ");
  fprintf(fp, "- ");
}


x86 assembly (clang, -O0):
<output_tag>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
xor    %eax,%eax
cmpl   $0x4,-0x14(%rbp)
mov    %al,-0x15(%rbp)
jge    1156 <output_tag+0x46>
xor    %eax,%eax
cmpq   $0x0,-0x10(%rbp)
mov    %al,-0x15(%rbp)
je     1156 <output_tag+0x46>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
setne  %al
mov    %al,-0x15(%rbp)
mov    -0x15(%rbp),%al
test   $0x1,%al
jne    1166 <output_tag+0x56>
jmp    1199 <output_tag+0x89>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rax
movsbl (%rax),%edx
lea    0xe88(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    1127 <output_tag+0x17>
jmp    119e <output_tag+0x8e>
cmpl   $0x4,-0x14(%rbp)
jge    11c8 <output_tag+0xb8>
mov    -0x8(%rbp),%rdi
lea    0xe51(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    119e <output_tag+0x8e>
mov    -0x8(%rbp),%rdi
lea    0xe30(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<output_tag>:
push   %rbp
push   %r14
push   %rbx
mov    %rdi,%rbx
xor    %ebp,%ebp
test   %rsi,%rsi
je     1188 <output_tag+0x68>
mov    %rsi,%r14
movsbl (%rsi),%edi
test   %edi,%edi
je     1188 <output_tag+0x68>
mov    %rbx,%rsi
call   1030 <fputc@plt>
movsbl 0x1(%r14),%edi
test   %edi,%edi
je     1175 <output_tag+0x55>
mov    %rbx,%rsi
call   1030 <fputc@plt>
movsbl 0x2(%r14),%edi
test   %edi,%edi
je     117c <output_tag+0x5c>
mov    %rbx,%rsi
call   1030 <fputc@plt>
movsbl 0x3(%r14),%edi
test   %edi,%edi
je     1183 <output_tag+0x63>
mov    %rbx,%rsi
call   1030 <fputc@plt>
jmp    11a1 <output_tag+0x81>
mov    $0x1,%ebp
jmp    1188 <output_tag+0x68>
mov    $0x2,%ebp
jmp    1188 <output_tag+0x68>
mov    $0x3,%ebp
or     $0xfffffffc,%ebp
nopl   0x0(%rax,%rax,1)
mov    $0x20,%edi
mov    %rbx,%rsi
call   1030 <fputc@plt>
inc    %ebp
jne    1190 <output_tag+0x70>
lea    0xe58(%rip),%rdi
mov    $0x2,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
pop    %rbx
pop    %r14
pop    %rbp
jmp    1040 <fwrite@plt>

LLVM IR (-O0):
@.str = [3 x i8] c"%c\00"
@.str.1 = [2 x i8] c" \00"
@.str.2 = [3 x i8] c"- \00"
define void @output_tag(i32* %0, i8* %1) {
%3 = alloca i32*
%4 = alloca i8*
%5 = alloca i32
store i32* %0, i32** %3
store i8* %1, i8** %4
store i32 0, i32* %5
br label %6
6: ; preds = %19, %2
%7 = load i32, i32* %5
%8 = icmp slt i32 %7, 4
br i1 %8, label %9, label %17
9: ; preds = %6
%10 = load i8*, i8** %4
%11 = icmp ne i8* %10, null
br i1 %11, label %12, label %17
12: ; preds = %9
%13 = load i8*, i8** %4
%14 = load i8, i8* %13
%15 = sext i8 %14 to i32
%16 = icmp ne i32 %15, 0
br label %17
17: ; preds = %12, %9, %6
%18 = phi i1 [ false, %9 ], [ false, %6 ], [ %16, %12 ]
br i1 %18, label %19, label %29
19: ; preds = %17
%20 = load i32*, i32** %3
%21 = load i8*, i8** %4
%22 = load i8, i8* %21
%23 = sext i8 %22 to i32
%24 = call i32 (i32*, i8*, ...) @fprintf(i32* %20, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %23)
%25 = load i32, i32* %5
%26 = add nsw i32 %25, 1
store i32 %26, i32* %5
%27 = load i8*, i8** %4
%28 = getelementptr inbounds i8, i8* %27, i32 1
store i8* %28, i8** %4
br label %6
29: ; preds = %17
br label %30
30: ; preds = %36, %29
%31 = load i32, i32* %5
%32 = icmp slt i32 %31, 4
br i1 %32, label %33, label %39
33: ; preds = %30
%34 = load i32*, i32** %3
%35 = call i32 (i32*, i8*, ...) @fprintf(i32* %34, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %36
36: ; preds = %33
%37 = load i32, i32* %5
%38 = add nsw i32 %37, 1
store i32 %38, i32* %5
br label %30
39: ; preds = %30
%40 = load i32*, i32** %3
%41 = call i32 (i32*, i8*, ...) @fprintf(i32* %40, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str.2 = [3 x i8] c"- \00"
define void @output_tag(i32* nocapture %0, i8* %1) {
%3 = icmp eq i8* %1, null
br i1 %3, label %25, label %4
4: ; preds = %2
%5 = load i8, i8* %1
%6 = icmp eq i8 %5, 0
br i1 %6, label %25, label %7
7: ; preds = %4
%8 = sext i8 %5 to i32
%9 = tail call i32 @fputc(i32 %8, i32* %0)
%10 = getelementptr inbounds i8, i8* %1, i64 1
%11 = load i8, i8* %10
%12 = icmp eq i8 %11, 0
br i1 %12, label %25, label %13
13: ; preds = %7
%14 = sext i8 %11 to i32
%15 = tail call i32 @fputc(i32 %14, i32* %0)
%16 = getelementptr inbounds i8, i8* %1, i64 2
%17 = load i8, i8* %16
%18 = icmp eq i8 %17, 0
br i1 %18, label %25, label %19
19: ; preds = %13
%20 = sext i8 %17 to i32
%21 = tail call i32 @fputc(i32 %20, i32* %0)
%22 = getelementptr inbounds i8, i8* %1, i64 3
%23 = load i8, i8* %22
%24 = icmp eq i8 %23, 0
br i1 %24, label %25, label %27
25: ; preds = %2, %4, %7, %13, %19
%26 = phi i32 [ 0, %2 ], [ 0, %4 ], [ 1, %7 ], [ 2, %13 ], [ 3, %19 ]
br label %30
27: ; preds = %19
%28 = sext i8 %23 to i32
%29 = tail call i32 @fputc(i32 %28, i32* %0)
br label %35
30: ; preds = %25, %30
%31 = phi i32 [ %33, %30 ], [ %26, %25 ]
%32 = tail call i32 @fputc(i32 32, i32* %0)
%33 = add nuw nsw i32 %31, 1
%34 = icmp eq i32 %33, 4
br i1 %34, label %35, label %30
35: ; preds = %30, %27
%36 = tail call i64 @fwrite(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i64 2, i64 1, i32* %0)
ret void
}