#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 *, ...);
char *strdup(char const *);
char toupper(char);
void guard_header(FILE *fp, const char *package) {
  char *upper;
  char *p;
  upper = p = strdup(package);
  while (*p) {
    *p = toupper(*p);
    p++;
  }
  fprintf(fp, "#ifndef __QMI_%s_H__\n", upper);
  fprintf(fp, "#define __QMI_%s_H__\n", upper);
  fprintf(fp, "\n");
}


x86 assembly (clang, -O0):
<guard_header>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <strdup@plt>
mov    %rax,-0x20(%rbp)
mov    %rax,-0x18(%rbp)
mov    -0x20(%rbp),%rax
cmpb   $0x0,(%rax)
je     1183 <guard_header+0x53>
mov    -0x20(%rbp),%rax
movsbl (%rax),%edi
call   1030 <toupper@plt>
mov    %al,%cl
mov    -0x20(%rbp),%rax
mov    %cl,(%rax)
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    1151 <guard_header+0x21>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rdx
lea    0xe6e(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rdx
lea    0xe6e(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x8(%rbp),%rdi
lea    0xe70(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<guard_header>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%r14
mov    %rsi,%rdi
call   1060 <strdup@plt>
mov    %rax,%r15
mov    (%rax),%al
test   %al,%al
je     1176 <guard_header+0x36>
mov    %r15,%rbx
add    $0x1,%rbx
movsbl %al,%edi
call   1030 <toupper@plt>
mov    %al,-0x1(%rbx)
movzbl (%rbx),%eax
add    $0x1,%rbx
test   %al,%al
jne    1160 <guard_header+0x20>
lea    0xe83(%rip),%rsi
mov    %r14,%rdi
mov    %r15,%rdx
xor    %eax,%eax
call   1050 <fprintf@plt>
lea    0xe85(%rip),%rsi
mov    %r14,%rdi
mov    %r15,%rdx
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    $0xa,%edi
mov    %r14,%rsi
pop    %rbx
pop    %r14
pop    %r15
jmp    1040 <fputc@plt>

LLVM IR (-O0):
@.str = [22 x i8] c"#ifndef __QMI_%s_H__\0A\00"
@.str.1 = [22 x i8] c"#define __QMI_%s_H__\0A\00"
@.str.2 = [2 x i8] c"\0A\00"
define void @guard_header(i32* %0, i8* %1) {
%3 = alloca i32*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
store i32* %0, i32** %3
store i8* %1, i8** %4
%7 = load i8*, i8** %4
%8 = call i8* @strdup(i8* %7)
store i8* %8, i8** %6
store i8* %8, i8** %5
br label %9
9: ; preds = %13, %2
%10 = load i8*, i8** %6
%11 = load i8, i8* %10
%12 = icmp ne i8 %11, 0
br i1 %12, label %13, label %20
13: ; preds = %9
%14 = load i8*, i8** %6
%15 = load i8, i8* %14
%16 = call signext i8 @toupper(i8 signext %15)
%17 = load i8*, i8** %6
store i8 %16, i8* %17
%18 = load i8*, i8** %6
%19 = getelementptr inbounds i8, i8* %18, i32 1
store i8* %19, i8** %6
br label %9
20: ; preds = %9
%21 = load i32*, i32** %3
%22 = load i8*, i8** %5
%23 = call i32 (i32*, i8*, ...) @fprintf(i32* %21, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i8* %22)
%24 = load i32*, i32** %3
%25 = load i8*, i8** %5
%26 = call i32 (i32*, i8*, ...) @fprintf(i32* %24, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i8* %25)
%27 = load i32*, i32** %3
%28 = call i32 (i32*, i8*, ...) @fprintf(i32* %27, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [22 x i8] c"#ifndef __QMI_%s_H__\0A\00"
@.str.1 = [22 x i8] c"#define __QMI_%s_H__\0A\00"
define void @guard_header(i32* nocapture %0, i8* nocapture %1) {
%3 = tail call i8* @strdup(i8* %1)
%4 = load i8, i8* %3
%5 = icmp eq i8 %4, 0
br i1 %5, label %13, label %6
6: ; preds = %2, %6
%7 = phi i8 [ %11, %6 ], [ %4, %2 ]
%8 = phi i8* [ %10, %6 ], [ %3, %2 ]
%9 = tail call signext i8 @toupper(i8 signext %7)
store i8 %9, i8* %8
%10 = getelementptr inbounds i8, i8* %8, i64 1
%11 = load i8, i8* %10
%12 = icmp eq i8 %11, 0
br i1 %12, label %13, label %6
13: ; preds = %6, %2
%14 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i8* %3)
%15 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i8* %3)
%16 = tail call i32 @fputc(i32 10, i32* %0)
ret void
}