#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*/ snprintf(char *, int, char *, char *, char *, ...);
scalar_t__ strlen(char *);
void GenHeader(char *exch, char *apsver, char *patchver, char *date, char *time,
               unsigned short jobnr, char *omt, char *user,
               unsigned short msggrp, unsigned short mask, char *hint,
               char *out, int len) {
  if (strlen(exch) == 0) {
    out[0] = 0;
    return;
  }
  char omtuser[32] = "";
  if (strlen(omt) && strlen(user)) {
    snprintf(omtuser, 32, "%s/%s", omt, user);
    omtuser[31] = '\0';
  }
  char left_part[100] = "";
  snprintf(left_part, 100, "%s/%s/%s", exch, apsver, patchver);
  left_part[99] = '\0';
  snprintf(out, len,
           "%-53s %8s  %8s\n%04d %14s                %04d/%05d %26s\n\n",
           left_part, date, time, jobnr, omtuser, msggrp, mask, hint);
  out[len - 1] = '\0';
}


x86 assembly (clang, -O0):
<GenHeader>:
push   %rbp
mov    %rsp,%rbp
push   %r14
push   %rbx
sub    $0xf0,%rsp
mov    %r9w,%ax
mov    0x40(%rbp),%r9d
mov    0x38(%rbp),%r9
mov    0x30(%rbp),%r9
mov    0x28(%rbp),%r9w
mov    0x20(%rbp),%r9w
mov    0x18(%rbp),%r9
mov    0x10(%rbp),%r9
mov    %rdi,-0x18(%rbp)
mov    %rsi,-0x20(%rbp)
mov    %rdx,-0x28(%rbp)
mov    %rcx,-0x30(%rbp)
mov    %r8,-0x38(%rbp)
mov    %ax,-0x3a(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <strlen@plt>
cmp    $0x0,%rax
jne    1197 <GenHeader+0x67>
mov    0x38(%rbp),%rax
movb   $0x0,(%rax)
jmp    1291 <GenHeader+0x161>
lea    -0x60(%rbp),%rdi
xor    %esi,%esi
mov    $0x20,%edx
call   1050 <memset@plt>
mov    0x10(%rbp),%rdi
call   1030 <strlen@plt>
cmp    $0x0,%rax
je     11f0 <GenHeader+0xc0>
mov    0x18(%rbp),%rdi
call   1030 <strlen@plt>
cmp    $0x0,%rax
je     11f0 <GenHeader+0xc0>
lea    -0x60(%rbp),%rdi
mov    0x10(%rbp),%rcx
mov    0x18(%rbp),%r8
mov    $0x20,%esi
lea    0xe1e(%rip),%rdx
mov    $0x0,%al
call   1040 <snprintf@plt>
movb   $0x0,-0x41(%rbp)
lea    -0xd0(%rbp),%rdi
xor    %esi,%esi
mov    $0x64,%edx
call   1050 <memset@plt>
lea    -0xd0(%rbp),%rdi
mov    -0x18(%rbp),%rcx
mov    -0x20(%rbp),%r8
mov    -0x28(%rbp),%r9
mov    $0x64,%esi
lea    0xdde(%rip),%rdx
mov    $0x0,%al
call   1040 <snprintf@plt>
movb   $0x0,-0x6d(%rbp)
mov    0x38(%rbp),%rdi
mov    0x40(%rbp),%esi
lea    -0xd0(%rbp),%rcx
mov    -0x30(%rbp),%r8
mov    -0x38(%rbp),%r9
movzwl -0x3a(%rbp),%r14d
lea    -0x60(%rbp),%rbx
movzwl 0x20(%rbp),%r11d
movzwl 0x28(%rbp),%r10d
mov    0x30(%rbp),%rax
lea    0xda8(%rip),%rdx
mov    %r14d,(%rsp)
mov    %rbx,0x8(%rsp)
mov    %r11d,0x10(%rsp)
mov    %r10d,0x18(%rsp)
mov    %rax,0x20(%rsp)
mov    $0x0,%al
call   1040 <snprintf@plt>
mov    0x38(%rbp),%rax
mov    0x40(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
add    $0xf0,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

x86 assembly (clang, -O2):
<GenHeader>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x98,%rsp
mov    0xf8(%rsp),%rax
cmpb   $0x0,(%rdi)
je     124e <GenHeader+0x13e>
mov    %r9d,%ebp
mov    %rcx,%r13
mov    %rdx,%rbx
mov    %rsi,%r14
mov    %rdi,%r15
mov    %r8,0x8(%rsp)
mov    0xd0(%rsp),%rcx
xorps  %xmm0,%xmm0
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
cmpb   $0x0,(%rcx)
je     118e <GenHeader+0x7e>
mov    0xd8(%rsp),%r8
cmpb   $0x0,(%r8)
je     118e <GenHeader+0x7e>
lea    0xe8e(%rip),%rdx
lea    0x10(%rsp),%rdi
mov    $0x20,%esi
xor    %eax,%eax
call   1030 <snprintf@plt>
xorps  %xmm0,%xmm0
movb   $0x0,0x2f(%rsp)
movaps %xmm0,0x80(%rsp)
movaps %xmm0,0x70(%rsp)
movaps %xmm0,0x60(%rsp)
movaps %xmm0,0x50(%rsp)
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x30(%rsp)
movl   $0x0,0x90(%rsp)
lea    0xe3f(%rip),%rdx
lea    0x30(%rsp),%r12
mov    %r12,%rdi
mov    $0x64,%esi
mov    %r15,%rcx
mov    %r14,%r8
mov    %rbx,%r9
xor    %eax,%eax
call   1030 <snprintf@plt>
movb   $0x0,0x93(%rsp)
movzwl %bp,%r10d
movzwl 0xe0(%rsp),%ebx
movzwl 0xe8(%rsp),%ebp
sub    $0x8,%rsp
lea    0x18(%rsp),%r11
lea    0xdff(%rip),%rdx
mov    0x100(%rsp),%r14
mov    %r14,%rdi
mov    0x108(%rsp),%r15d
mov    %r15d,%esi
mov    %r12,%rcx
mov    %r13,%r8
mov    0x10(%rsp),%r9
xor    %eax,%eax
push   0xf8(%rsp)
push   %rbp
push   %rbx
push   %r11
push   %r10
call   1030 <snprintf@plt>
add    $0x30,%rsp
movslq %r15d,%rax
movb   $0x0,-0x1(%rax,%r14,1)
jmp    1251 <GenHeader+0x141>
movb   $0x0,(%rax)
add    $0x98,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [6 x i8] c"%s/%s\00"
@.str.1 = [9 x i8] c"%s/%s/%s\00"
@.str.2 = [57 x i8] c"%-53s %8s %8s\0A%04d %14s %04d/%05d %26s\0A\0A\00"
define void @GenHeader(i8* %0, i8* %1, i8* %2, i8* %3, i8* %4, i16 zeroext %5, i8* %6, i8* %7, i16 zeroext %8, i16 zeroext %9, i8* %10, i8* %11, i32 %12) {
%14 = alloca i8*
%15 = alloca i8*
%16 = alloca i8*
%17 = alloca i8*
%18 = alloca i8*
%19 = alloca i16
%20 = alloca i8*
%21 = alloca i8*
%22 = alloca i16
%23 = alloca i16
%24 = alloca i8*
%25 = alloca i8*
%26 = alloca i32
%27 = alloca [32 x i8]
%28 = alloca [100 x i8]
store i8* %0, i8** %14
store i8* %1, i8** %15
store i8* %2, i8** %16
store i8* %3, i8** %17
store i8* %4, i8** %18
store i16 %5, i16* %19
store i8* %6, i8** %20
store i8* %7, i8** %21
store i16 %8, i16* %22
store i16 %9, i16* %23
store i8* %10, i8** %24
store i8* %11, i8** %25
store i32 %12, i32* %26
%29 = load i8*, i8** %14
%30 = call i64 @strlen(i8* %29)
%31 = icmp eq i64 %30, 0
br i1 %31, label %32, label %35
32: ; preds = %13
%33 = load i8*, i8** %25
%34 = getelementptr inbounds i8, i8* %33, i64 0
store i8 0, i8* %34
br label %77
35: ; preds = %13
%36 = bitcast [32 x i8]* %27 to i8*
%37 = load i8*, i8** %20
%38 = call i64 @strlen(i8* %37)
%39 = icmp ne i64 %38, 0
br i1 %39, label %40, label %50
40: ; preds = %35
%41 = load i8*, i8** %21
%42 = call i64 @strlen(i8* %41)
%43 = icmp ne i64 %42, 0
br i1 %43, label %44, label %50
44: ; preds = %40
%45 = getelementptr inbounds [32 x i8], [32 x i8]* %27, i64 0, i64 0
%46 = load i8*, i8** %20
%47 = load i8*, i8** %21
%48 = call i32 (i8*, i32, i8*, i8*, i8*, ...) @snprintf(i8* %45, i32 32, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %46, i8* %47)
%49 = getelementptr inbounds [32 x i8], [32 x i8]* %27, i64 0, i64 31
store i8 0, i8* %49
br label %50
50: ; preds = %44, %40, %35
%51 = bitcast [100 x i8]* %28 to i8*
%52 = getelementptr inbounds [100 x i8], [100 x i8]* %28, i64 0, i64 0
%53 = load i8*, i8** %14
%54 = load i8*, i8** %15
%55 = load i8*, i8** %16
%56 = call i32 (i8*, i32, i8*, i8*, i8*, ...) @snprintf(i8* %52, i32 100, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8* %53, i8* %54, i8* %55)
%57 = getelementptr inbounds [100 x i8], [100 x i8]* %28, i64 0, i64 99
store i8 0, i8* %57
%58 = load i8*, i8** %25
%59 = load i32, i32* %26
%60 = getelementptr inbounds [100 x i8], [100 x i8]* %28, i64 0, i64 0
%61 = load i8*, i8** %17
%62 = load i8*, i8** %18
%63 = load i16, i16* %19
%64 = zext i16 %63 to i32
%65 = getelementptr inbounds [32 x i8], [32 x i8]* %27, i64 0, i64 0
%66 = load i16, i16* %22
%67 = zext i16 %66 to i32
%68 = load i16, i16* %23
%69 = zext i16 %68 to i32
%70 = load i8*, i8** %24
%71 = call i32 (i8*, i32, i8*, i8*, i8*, ...) @snprintf(i8* %58, i32 %59, i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str.2, i64 0, i64 0), i8* %60, i8* %61, i8* %62, i32 %64, i8* %65, i32 %67, i32 %69, i8* %70)
%72 = load i8*, i8** %25
%73 = load i32, i32* %26
%74 = sub nsw i32 %73, 1
%75 = sext i32 %74 to i64
%76 = getelementptr inbounds i8, i8* %72, i64 %75
store i8 0, i8* %76
br label %77
77: ; preds = %50, %32
ret void
}

LLVM IR (-O2):
@.str = [6 x i8] c"%s/%s\00"
@.str.1 = [9 x i8] c"%s/%s/%s\00"
@.str.2 = [57 x i8] c"%-53s %8s %8s\0A%04d %14s %04d/%05d %26s\0A\0A\00"
define void @GenHeader(i8* %0, i8* %1, i8* %2, i8* %3, i8* %4, i16 zeroext %5, i8* %6, i8* %7, i16 zeroext %8, i16 zeroext %9, i8* %10, i8* %11, i32 %12) {
%14 = alloca [32 x i8]
%15 = alloca [100 x i8]
%16 = load i8, i8* %0
%17 = icmp eq i8 %16, 0
br i1 %17, label %18, label %19
18: ; preds = %13
store i8 0, i8* %11
br label %40
19: ; preds = %13
%20 = getelementptr inbounds [32 x i8], [32 x i8]* %14, i64 0, i64 0
%21 = load i8, i8* %6
%22 = icmp eq i8 %21, 0
br i1 %22, label %29, label %23
23: ; preds = %19
%24 = load i8, i8* %7
%25 = icmp eq i8 %24, 0
br i1 %25, label %29, label %26
26: ; preds = %23
%27 = call i32 (i8*, i32, i8*, i8*, i8*, ...) @snprintf(i8* %20, i32 32, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %6, i8* %7)
%28 = getelementptr inbounds [32 x i8], [32 x i8]* %14, i64 0, i64 31
store i8 0, i8* %28
br label %29
29: ; preds = %26, %23, %19
%30 = getelementptr inbounds [100 x i8], [100 x i8]* %15, i64 0, i64 0
%31 = call i32 (i8*, i32, i8*, i8*, i8*, ...) @snprintf(i8* %30, i32 100, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8* %0, i8* %1, i8* %2)
%32 = getelementptr inbounds [100 x i8], [100 x i8]* %15, i64 0, i64 99
store i8 0, i8* %32
%33 = zext i16 %5 to i32
%34 = zext i16 %8 to i32
%35 = zext i16 %9 to i32
%36 = call i32 (i8*, i32, i8*, i8*, i8*, ...) @snprintf(i8* %11, i32 %12, i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str.2, i64 0, i64 0), i8* %30, i8* %3, i8* %4, i32 %33, i8* %20, i32 %34, i32 %35, i8* %10)
%37 = add nsw i32 %12, -1
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds i8, i8* %11, i64 %38
store i8 0, i8* %39
br label %40
40: ; preds = %29, %18
ret void
}