#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*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, char *, char *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ strcat(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int /*<<< orphan*/ strcpy1(char *, char *, int);
void writeheading(char *jobnamec, char *heading, int *nheading_) {
  FILE *f1;
  char p1[6] = "    1", fneig[132] = "", c[2] = "C",
       text[67] =
           "                                                                  ";
  int i;
  strcpy(fneig, jobnamec);
  strcat(fneig, ".frd");
  if ((f1 = fopen(fneig, "ab")) == NULL) {
    printf("*ERROR in frd: cannot open frd file for writing...");
    exit(0);
  }
  fprintf(f1, "%5s%1s\n", p1, c);
  for (i = 0; i < *nheading_; i++) {
    strcpy1(text, &heading[66 * i], 66);
    fprintf(f1, "%5sU%66s\n", p1, text);
  }
  fclose(f1);
  return;
}


x86 assembly (clang, -O0):
<writeheading>:
push   %rbp
mov    %rsp,%rbp
sub    $0x110,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    0xe43(%rip),%eax
mov    %eax,-0x26(%rbp)
mov    0xe3d(%rip),%ax
mov    %ax,-0x22(%rbp)
lea    -0xb0(%rbp),%rdi
xor    %esi,%esi
mov    $0x84,%edx
call   1060 <memset@plt>
mov    0xe21(%rip),%ax
mov    %ax,-0xb2(%rbp)
lea    -0x100(%rbp),%rdi
lea    0xe66(%rip),%rsi
mov    $0x43,%edx
call   1090 <memcpy@plt>
lea    -0xb0(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1030 <strcpy@plt>
lea    -0xb0(%rbp),%rdi
lea    0xde6(%rip),%rsi
call   10b0 <strcat@plt>
lea    -0xb0(%rbp),%rdi
lea    0xdd8(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
jne    125b <writeheading+0xbb>
lea    0xdc1(%rip),%rdi
call   1050 <printf@plt>
xor    %edi,%edi
call   10c0 <exit@plt>
mov    -0x20(%rbp),%rdi
lea    -0x26(%rbp),%rdx
lea    -0xb2(%rbp),%rcx
lea    0xdd2(%rip),%rsi
call   1070 <fprintf@plt>
movl   $0x0,-0x104(%rbp)
mov    -0x104(%rbp),%eax
mov    -0x18(%rbp),%rcx
cmp    (%rcx),%eax
jge    12e2 <writeheading+0x142>
lea    -0x100(%rbp),%rdi
mov    -0x10(%rbp),%rsi
imul   $0x42,-0x104(%rbp),%eax
cltq
add    %rax,%rsi
mov    $0x42,%edx
call   1080 <strcpy1@plt>
mov    -0x20(%rbp),%rdi
lea    -0x26(%rbp),%rdx
lea    -0x100(%rbp),%rcx
lea    0xd82(%rip),%rsi
call   1070 <fprintf@plt>
mov    -0x104(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x104(%rbp)
jmp    1280 <writeheading+0xe0>
mov    -0x20(%rbp),%rdi
call   1040 <fclose@plt>
add    $0x110,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<writeheading>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xe8,%rsp
mov    %rdx,%r13
mov    %rsi,%rbx
mov    %rdi,%rsi
movw   $0x31,0xc(%rsp)
movl   $0x20202020,0x8(%rsp)
20
xorps  %xmm0,%xmm0
movaps %xmm0,0xd0(%rsp)
movaps %xmm0,0xc0(%rsp)
movaps %xmm0,0xb0(%rsp)
movaps %xmm0,0xa0(%rsp)
movaps %xmm0,0x90(%rsp)
movaps %xmm0,0x80(%rsp)
movaps %xmm0,0x70(%rsp)
movaps %xmm0,0x60(%rsp)
movl   $0x0,0xe0(%rsp)
movw   $0x43,0x6(%rsp)
movaps 0xe91(%rip),%xmm0
movaps %xmm0,0x40(%rsp)
movaps 0xe75(%rip),%xmm0
movaps %xmm0,0x30(%rsp)
movaps 0xe59(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movaps 0xe3d(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movl   $0x202020,0x4f(%rsp)
lea    0x60(%rsp),%rbp
mov    %rbp,%rdi
call   1030 <strcpy@plt>
lea    0xdc2(%rip),%rsi
mov    %rbp,%rdi
call   1090 <strcat@plt>
lea    0xdb8(%rip),%rsi
mov    %rbp,%rdi
call   1080 <fopen@plt>
test   %rax,%rax
je     12f0 <writeheading+0x170>
mov    %rax,%r15
lea    0xdd3(%rip),%rsi
lea    0x8(%rsp),%rdx
lea    0x6(%rsp),%rcx
mov    %rax,%rdi
call   1060 <fprintf@plt>
cmpl   $0x0,0x0(%r13)
jle    12d6 <writeheading+0x156>
xor    %r14d,%r14d
lea    0x10(%rsp),%r12
lea    0x8(%rsp),%rbp
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r12,%rdi
mov    %rbx,%rsi
mov    $0x42,%edx
call   1070 <strcpy1@plt>
mov    %r15,%rdi
lea    0xd8f(%rip),%rsi
mov    %rbp,%rdx
mov    %r12,%rcx
call   1060 <fprintf@plt>
add    $0x1,%r14
movslq 0x0(%r13),%rax
add    $0x42,%rbx
cmp    %rax,%r14
jl     12a0 <writeheading+0x120>
mov    %r15,%rdi
call   1040 <fclose@plt>
add    $0xe8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xd17(%rip),%rdi
call   1050 <printf@plt>
xor    %edi,%edi
call   10a0 <exit@plt>

LLVM IR (-O0):
@__const.writeheading.p1 = [6 x i8] c" 1\00"
@__const.writeheading.c = [2 x i8] c"C\00"
@__const.writeheading.text = [67 x i8] c" \00"
@.str = [5 x i8] c".frd\00"
@.str.1 = [3 x i8] c"ab\00"
@.str.2 = [51 x i8] c"*ERROR in frd: cannot open frd file for writing...\00"
@.str.3 = [8 x i8] c"%5s%1s\0A\00"
@.str.4 = [10 x i8] c"%5sU%66s\0A\00"
define void @writeheading(i8* %0, i8* %1, i32* %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32*
%7 = alloca i32*
%8 = alloca [6 x i8]
%9 = alloca [132 x i8]
%10 = alloca [2 x i8]
%11 = alloca [67 x i8]
%12 = alloca i32
store i8* %0, i8** %4
store i8* %1, i8** %5
store i32* %2, i32** %6
%13 = bitcast [6 x i8]* %8 to i8*
%14 = bitcast [132 x i8]* %9 to i8*
%15 = bitcast [2 x i8]* %10 to i8*
%16 = bitcast [67 x i8]* %11 to i8*
%17 = getelementptr inbounds [132 x i8], [132 x i8]* %9, i64 0, i64 0
%18 = load i8*, i8** %4
%19 = call i32 @strcpy(i8* %17, i8* %18)
%20 = getelementptr inbounds [132 x i8], [132 x i8]* %9, i64 0, i64 0
%21 = call i32 @strcat(i8* %20, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%22 = getelementptr inbounds [132 x i8], [132 x i8]* %9, i64 0, i64 0
%23 = call i32* @fopen(i8* %22, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %23, i32** %7
%24 = icmp eq i32* %23, null
br i1 %24, label %25, label %28
25: ; preds = %3
%26 = call i32 @printf(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.2, i64 0, i64 0))
%27 = call i32 @exit(i32 0)
unreachable
28: ; preds = %3
%29 = load i32*, i32** %7
%30 = getelementptr inbounds [6 x i8], [6 x i8]* %8, i64 0, i64 0
%31 = getelementptr inbounds [2 x i8], [2 x i8]* %10, i64 0, i64 0
%32 = call i32 @fprintf(i32* %29, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i8* %30, i8* %31)
store i32 0, i32* %12
br label %33
33: ; preds = %50, %28
%34 = load i32, i32* %12
%35 = load i32*, i32** %6
%36 = load i32, i32* %35
%37 = icmp slt i32 %34, %36
br i1 %37, label %38, label %53
38: ; preds = %33
%39 = getelementptr inbounds [67 x i8], [67 x i8]* %11, i64 0, i64 0
%40 = load i8*, i8** %5
%41 = load i32, i32* %12
%42 = mul nsw i32 66, %41
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds i8, i8* %40, i64 %43
%45 = call i32 @strcpy1(i8* %39, i8* %44, i32 66)
%46 = load i32*, i32** %7
%47 = getelementptr inbounds [6 x i8], [6 x i8]* %8, i64 0, i64 0
%48 = getelementptr inbounds [67 x i8], [67 x i8]* %11, i64 0, i64 0
%49 = call i32 @fprintf(i32* %46, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0), i8* %47, i8* %48)
br label %50
50: ; preds = %38
%51 = load i32, i32* %12
%52 = add nsw i32 %51, 1
store i32 %52, i32* %12
br label %33
53: ; preds = %33
%54 = load i32*, i32** %7
%55 = call i32 @fclose(i32* %54)
ret void
}

LLVM IR (-O2):
@__const.writeheading.p1 = [6 x i8] c" 1\00"
@__const.writeheading.text = [67 x i8] c" \00"
@.str = [5 x i8] c".frd\00"
@.str.1 = [3 x i8] c"ab\00"
@.str.2 = [51 x i8] c"*ERROR in frd: cannot open frd file for writing...\00"
@.str.3 = [8 x i8] c"%5s%1s\0A\00"
@.str.4 = [10 x i8] c"%5sU%66s\0A\00"
define void @writeheading(i8* %0, i8* %1, i32* nocapture %2) {
%4 = alloca [6 x i8]
%5 = alloca [132 x i8]
%6 = alloca i16
%7 = alloca [67 x i8]
%8 = getelementptr inbounds [6 x i8], [6 x i8]* %4, i64 0, i64 0
%9 = getelementptr inbounds [132 x i8], [132 x i8]* %5, i64 0, i64 0
%10 = bitcast i16* %6 to i8*
store i16 67, i16* %6
%11 = getelementptr inbounds [67 x i8], [67 x i8]* %7, i64 0, i64 0
%12 = call i32 @strcpy(i8* %9, i8* %0)
%13 = call i32 @strcat(i8* %9, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%14 = call i32* @fopen(i8* %9, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%15 = icmp eq i32* %14, null
br i1 %15, label %16, label %19
16: ; preds = %3
%17 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([51 x i8], [51 x i8]* @.str.2, i64 0, i64 0))
%18 = call i32 @exit(i32 0)
unreachable
19: ; preds = %3
%20 = call i32 @fprintf(i32* %14, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i8* %8, i8* %10)
%21 = load i32, i32* %2
%22 = icmp sgt i32 %21, 0
br i1 %22, label %23, label %33
23: ; preds = %19, %23
%24 = phi i64 [ %29, %23 ], [ 0, %19 ]
%25 = mul nuw nsw i64 %24, 66
%26 = getelementptr inbounds i8, i8* %1, i64 %25
%27 = call i32 @strcpy1(i8* %11, i8* %26, i32 66)
%28 = call i32 @fprintf(i32* %14, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0), i8* %8, i8* %11)
%29 = add nuw nsw i64 %24, 1
%30 = load i32, i32* %2
%31 = sext i32 %30 to i64
%32 = icmp slt i64 %29, %31
br i1 %32, label %23, label %33
33: ; preds = %23, %19
%34 = call i32 @fclose(i32* %14)
ret void
}