#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 const *, ...);
int /*<<< orphan*/ isspace(char const);
int /*<<< orphan*/ putc(char const, int /*<<< orphan*/ *);
long strlen(char const *);
int /*<<< orphan*/ t_error(char *);
void write_comment(FILE *outputfile, const char *comment, long columns) {
  const char opening[5] = "/** ", closing[4] = " */";
  long i, j, len;
  if (outputfile == NULL) {
    t_error("An attempt was made to write on a not opened file");
  } else if (comment != NULL) {
    len = strlen(comment);
    putc('\n', outputfile);
    fprintf(outputfile, "%s", opening);
    j = 5;
    for (i = 0; i < len; i++) {
      if (j < columns) {
        if (comment[i] != '\n' && comment[i] != '\t') {
          putc(comment[i], outputfile);
        } else {
          putc(' ', outputfile);
        }
        j++;
      }
      if (j == columns && !isspace(comment[i - 1])) {
        putc('-', outputfile);
        putc('\n', outputfile);
        j = 0;
      }
    }
    if (j + 2 < columns) {
      fprintf(outputfile, closing);
    } else {
      putc('\n', outputfile);
      fprintf(outputfile, closing);
    }
    putc('\n', outputfile);
  }
}


x86 assembly (clang, -O0):
<write_comment>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    0xe96(%rip),%eax
mov    %eax,-0x1d(%rbp)
mov    0xe91(%rip),%al
mov    %al,-0x19(%rbp)
mov    0xe89(%rip),%eax
mov    %eax,-0x21(%rbp)
cmpq   $0x0,-0x8(%rbp)
jne    119b <write_comment+0x4b>
lea    0xe78(%rip),%rdi
call   1070 <t_error@plt>
jmp    131f <write_comment+0x1cf>
cmpq   $0x0,-0x10(%rbp)
je     131a <write_comment+0x1ca>
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %rax,-0x40(%rbp)
mov    -0x8(%rbp),%rsi
mov    $0xa,%edi
call   1050 <putc@plt>
mov    -0x8(%rbp),%rdi
lea    -0x1d(%rbp),%rdx
lea    0xe6b(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
movq   $0x5,-0x38(%rbp)
movq   $0x0,-0x30(%rbp)
mov    -0x30(%rbp),%rax
cmp    -0x40(%rbp),%rax
jge    12c9 <write_comment+0x179>
mov    -0x38(%rbp),%rax
cmp    -0x18(%rbp),%rax
jge    1263 <write_comment+0x113>
mov    -0x10(%rbp),%rax
mov    -0x30(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0xa,%eax
je     1249 <write_comment+0xf9>
mov    -0x10(%rbp),%rax
mov    -0x30(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x9,%eax
je     1249 <write_comment+0xf9>
mov    -0x10(%rbp),%rax
mov    -0x30(%rbp),%rcx
mov    (%rax,%rcx,1),%al
mov    -0x8(%rbp),%rsi
movsbl %al,%edi
call   1050 <putc@plt>
jmp    1257 <write_comment+0x107>
mov    -0x8(%rbp),%rsi
mov    $0x20,%edi
call   1050 <putc@plt>
mov    -0x38(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rax
cmp    -0x18(%rbp),%rax
jne    12b3 <write_comment+0x163>
mov    -0x10(%rbp),%rax
mov    -0x30(%rbp),%rcx
sub    $0x1,%rcx
movsbl (%rax,%rcx,1),%edi
call   1040 <isspace@plt>
cmp    $0x0,%eax
jne    12b3 <write_comment+0x163>
mov    -0x8(%rbp),%rsi
mov    $0x2d,%edi
call   1050 <putc@plt>
mov    -0x8(%rbp),%rsi
mov    $0xa,%edi
call   1050 <putc@plt>
movq   $0x0,-0x38(%rbp)
jmp    12b8 <write_comment+0x168>
mov    -0x30(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x30(%rbp)
jmp    11e7 <write_comment+0x97>
mov    -0x38(%rbp),%rax
add    $0x2,%rax
cmp    -0x18(%rbp),%rax
jge    12ef <write_comment+0x19f>
mov    -0x8(%rbp),%rdi
lea    -0x21(%rbp),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
jmp    130c <write_comment+0x1bc>
mov    -0x8(%rbp),%rsi
mov    $0xa,%edi
call   1050 <putc@plt>
mov    -0x8(%rbp),%rdi
lea    -0x21(%rbp),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    -0x8(%rbp),%rsi
mov    $0xa,%edi
call   1050 <putc@plt>
jmp    131f <write_comment+0x1cf>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<write_comment>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
movb   $0x0,0x10(%rsp)
movl   $0x202a2a2f,0xc(%rsp)
20
movl   $0x2f2a20,0x14(%rsp)
test   %rdi,%rdi
je     1286 <write_comment+0x126>
mov    %rsi,%r15
test   %rsi,%rsi
je     12a0 <write_comment+0x140>
mov    %rdx,%rbp
mov    %rdi,%r14
mov    %r15,%rdi
call   1030 <strlen@plt>
mov    %rax,%r12
mov    $0xa,%edi
mov    %r14,%rsi
call   1060 <putc@plt>
lea    0xc(%rsp),%rdi
mov    %r14,%rsi
call   1040 <fputs@plt>
mov    $0x5,%r13d
test   %r12,%r12
jle    1246 <write_comment+0xe6>
xor    %ebx,%ebx
jmp    11e9 <write_comment+0x89>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
add    $0x1,%rbx
cmp    %rbx,%r12
je     1246 <write_comment+0xe6>
cmp    %rbp,%r13
jge    1210 <write_comment+0xb0>
movzbl (%r15,%rbx,1),%eax
lea    -0x9(%rax),%ecx
cmp    $0x2,%cl
mov    $0x20,%ecx
cmovb  %ecx,%eax
movsbl %al,%edi
mov    %r14,%rsi
call   1060 <putc@plt>
add    $0x1,%r13
cmp    %rbp,%r13
jne    11e0 <write_comment+0x80>
movsbl -0x1(%r15,%rbx,1),%edi
call   1050 <isspace@plt>
mov    %rbp,%r13
test   %eax,%eax
jne    11e0 <write_comment+0x80>
mov    $0x2d,%edi
mov    %r14,%rsi
call   1060 <putc@plt>
mov    $0xa,%edi
mov    %r14,%rsi
call   1060 <putc@plt>
xor    %r13d,%r13d
jmp    11e0 <write_comment+0x80>
add    $0x2,%r13
cmp    %rbp,%r13
jl     125c <write_comment+0xfc>
mov    $0xa,%edi
mov    %r14,%rsi
call   1060 <putc@plt>
lea    0x14(%rsp),%rsi
mov    %r14,%rdi
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    $0xa,%edi
mov    %r14,%rsi
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1060 <putc@plt>
lea    0xd78(%rip),%rdi
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1080 <t_error@plt>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@__const.write_comment.opening = [5 x i8] c"/** \00"
@__const.write_comment.closing = [4 x i8] c" */\00"
@.str = [50 x i8] c"An attempt was made to write on a not opened file\00"
@.str.1 = [3 x i8] c"%s\00"
define void @write_comment(i32* %0, i8* %1, i64 %2) {
%4 = alloca i32*
%5 = alloca i8*
%6 = alloca i64
%7 = alloca [5 x i8]
%8 = alloca [4 x i8]
%9 = alloca i64
%10 = alloca i64
%11 = alloca i64
store i32* %0, i32** %4
store i8* %1, i8** %5
store i64 %2, i64* %6
%12 = bitcast [5 x i8]* %7 to i8*
%13 = bitcast [4 x i8]* %8 to i8*
%14 = load i32*, i32** %4
%15 = icmp eq i32* %14, null
br i1 %15, label %16, label %18
16: ; preds = %3
%17 = call i32 @t_error(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str, i64 0, i64 0))
br label %104
18: ; preds = %3
%19 = load i8*, i8** %5
%20 = icmp ne i8* %19, null
br i1 %20, label %21, label %103
21: ; preds = %18
%22 = load i8*, i8** %5
%23 = call i64 @strlen(i8* %22)
store i64 %23, i64* %11
%24 = load i32*, i32** %4
%25 = call i32 @putc(i8 signext 10, i32* %24)
%26 = load i32*, i32** %4
%27 = getelementptr inbounds [5 x i8], [5 x i8]* %7, i64 0, i64 0
%28 = call i32 (i32*, i8*, ...) @fprintf(i32* %26, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %27)
store i64 5, i64* %10
store i64 0, i64* %9
br label %29
29: ; preds = %82, %21
%30 = load i64, i64* %9
%31 = load i64, i64* %11
%32 = icmp slt i64 %30, %31
br i1 %32, label %33, label %85
33: ; preds = %29
%34 = load i64, i64* %10
%35 = load i64, i64* %6
%36 = icmp slt i64 %34, %35
br i1 %36, label %37, label %64
37: ; preds = %33
%38 = load i8*, i8** %5
%39 = load i64, i64* %9
%40 = getelementptr inbounds i8, i8* %38, i64 %39
%41 = load i8, i8* %40
%42 = sext i8 %41 to i32
%43 = icmp ne i32 %42, 10
br i1 %43, label %44, label %58
44: ; preds = %37
%45 = load i8*, i8** %5
%46 = load i64, i64* %9
%47 = getelementptr inbounds i8, i8* %45, i64 %46
%48 = load i8, i8* %47
%49 = sext i8 %48 to i32
%50 = icmp ne i32 %49, 9
br i1 %50, label %51, label %58
51: ; preds = %44
%52 = load i8*, i8** %5
%53 = load i64, i64* %9
%54 = getelementptr inbounds i8, i8* %52, i64 %53
%55 = load i8, i8* %54
%56 = load i32*, i32** %4
%57 = call i32 @putc(i8 signext %55, i32* %56)
br label %61
58: ; preds = %44, %37
%59 = load i32*, i32** %4
%60 = call i32 @putc(i8 signext 32, i32* %59)
br label %61
61: ; preds = %58, %51
%62 = load i64, i64* %10
%63 = add nsw i64 %62, 1
store i64 %63, i64* %10
br label %64
64: ; preds = %61, %33
%65 = load i64, i64* %10
%66 = load i64, i64* %6
%67 = icmp eq i64 %65, %66
br i1 %67, label %68, label %81
68: ; preds = %64
%69 = load i8*, i8** %5
%70 = load i64, i64* %9
%71 = sub nsw i64 %70, 1
%72 = getelementptr inbounds i8, i8* %69, i64 %71
%73 = load i8, i8* %72
%74 = call i32 @isspace(i8 signext %73)
%75 = icmp ne i32 %74, 0
br i1 %75, label %81, label %76
76: ; preds = %68
%77 = load i32*, i32** %4
%78 = call i32 @putc(i8 signext 45, i32* %77)
%79 = load i32*, i32** %4
%80 = call i32 @putc(i8 signext 10, i32* %79)
store i64 0, i64* %10
br label %81
81: ; preds = %76, %68, %64
br label %82
82: ; preds = %81
%83 = load i64, i64* %9
%84 = add nsw i64 %83, 1
store i64 %84, i64* %9
br label %29
85: ; preds = %29
%86 = load i64, i64* %10
%87 = add nsw i64 %86, 2
%88 = load i64, i64* %6
%89 = icmp slt i64 %87, %88
br i1 %89, label %90, label %94
90: ; preds = %85
%91 = load i32*, i32** %4
%92 = getelementptr inbounds [4 x i8], [4 x i8]* %8, i64 0, i64 0
%93 = call i32 (i32*, i8*, ...) @fprintf(i32* %91, i8* %92)
br label %100
94: ; preds = %85
%95 = load i32*, i32** %4
%96 = call i32 @putc(i8 signext 10, i32* %95)
%97 = load i32*, i32** %4
%98 = getelementptr inbounds [4 x i8], [4 x i8]* %8, i64 0, i64 0
%99 = call i32 (i32*, i8*, ...) @fprintf(i32* %97, i8* %98)
br label %100
100: ; preds = %94, %90
%101 = load i32*, i32** %4
%102 = call i32 @putc(i8 signext 10, i32* %101)
br label %103
103: ; preds = %100, %18
br label %104
104: ; preds = %103, %16
ret void
}

LLVM IR (-O2):
@__const.write_comment.opening = [5 x i8] c"/** \00"
@.str = [50 x i8] c"An attempt was made to write on a not opened file\00"
define void @write_comment(i32* %0, i8* %1, i64 %2) {
%4 = alloca [5 x i8]
%5 = alloca i32
%6 = getelementptr inbounds [5 x i8], [5 x i8]* %4, i64 0, i64 0
%7 = bitcast i32* %5 to i8*
store i32 3090976, i32* %5
%8 = icmp eq i32* %0, null
br i1 %8, label %9, label %11
9: ; preds = %3
%10 = tail call i32 @t_error(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str, i64 0, i64 0))
br label %55
11: ; preds = %3
%12 = icmp eq i8* %1, null
br i1 %12, label %55, label %13
13: ; preds = %11
%14 = tail call i64 @strlen(i8* %1)
%15 = tail call i32 @putc(i8 signext 10, i32* %0)
%16 = call i32 @fputs(i8* %6, i32* %0)
%17 = icmp sgt i64 %14, 0
br i1 %17, label %18, label %46
18: ; preds = %13, %42
%19 = phi i64 [ %44, %42 ], [ 0, %13 ]
%20 = phi i64 [ %43, %42 ], [ 5, %13 ]
%21 = icmp slt i64 %20, %2
br i1 %21, label %22, label %30
22: ; preds = %18
%23 = getelementptr inbounds i8, i8* %1, i64 %19
%24 = load i8, i8* %23
%25 = add i8 %24, -9
%26 = icmp ult i8 %25, 2
%27 = select i1 %26, i8 32, i8 %24
%28 = tail call i32 @putc(i8 signext %27, i32* %0)
%29 = add nsw i64 %20, 1
br label %30
30: ; preds = %22, %18
%31 = phi i64 [ %29, %22 ], [ %20, %18 ]
%32 = icmp eq i64 %31, %2
br i1 %32, label %33, label %42
33: ; preds = %30
%34 = add nsw i64 %19, -1
%35 = getelementptr inbounds i8, i8* %1, i64 %34
%36 = load i8, i8* %35
%37 = tail call i32 @isspace(i8 signext %36)
%38 = icmp eq i32 %37, 0
br i1 %38, label %39, label %42
39: ; preds = %33
%40 = tail call i32 @putc(i8 signext 45, i32* %0)
%41 = tail call i32 @putc(i8 signext 10, i32* %0)
br label %42
42: ; preds = %30, %33, %39
%43 = phi i64 [ %2, %33 ], [ 0, %39 ], [ %31, %30 ]
%44 = add nuw nsw i64 %19, 1
%45 = icmp eq i64 %44, %14
br i1 %45, label %46, label %18
46: ; preds = %42, %13
%47 = phi i64 [ 5, %13 ], [ %43, %42 ]
%48 = add nsw i64 %47, 2
%49 = icmp slt i64 %48, %2
br i1 %49, label %52, label %50
50: ; preds = %46
%51 = tail call i32 @putc(i8 signext 10, i32* %0)
br label %52
52: ; preds = %46, %50
%53 = call i32 (i32*, i8*, ...) @fprintf(i32* %0, i8* %7)
%54 = tail call i32 @putc(i8 signext 10, i32* %0)
br label %55
55: ; preds = %11, %52, %9
ret void
}