#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 */
scalar_t__ isspace(char);
int /*<<< orphan*/ snprintf(char *, int, char *, char *);
int strlen(char *);
void guess_script_title_from_first_line(char *src, char *dst, int maxsize) {
  while (isspace(*src) || *src == '/' || *src == '*')
    src++;
  snprintf(dst, maxsize, "%s", src);
  for (char *c = dst; *c; c++)
    if (*c == '\n') {
      *c = 0;
      break;
    }
  char *last = dst + strlen(dst) - 1;
  while (isspace(*last) || *last == '/' || *last == '*')
    last--;
  last++;
  if (last > dst)
    *last = 0;
}


x86 assembly (clang, -O0):
<guess_script_title_from_first_line>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x8(%rbp),%rax
movsbl (%rax),%edi
call   1050 <isspace@plt>
mov    %rax,%rcx
mov    $0x1,%al
cmp    $0x0,%rcx
mov    %al,-0x29(%rbp)
jne    1186 <guess_script_title_from_first_line+0x56>
mov    -0x8(%rbp),%rax
movsbl (%rax),%ecx
mov    $0x1,%al
cmp    $0x2f,%ecx
mov    %al,-0x29(%rbp)
je     1186 <guess_script_title_from_first_line+0x56>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2a,%eax
sete   %al
mov    %al,-0x29(%rbp)
mov    -0x29(%rbp),%al
test   $0x1,%al
jne    1196 <guess_script_title_from_first_line+0x66>
jmp    11a7 <guess_script_title_from_first_line+0x77>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    1143 <guess_script_title_from_first_line+0x13>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x8(%rbp),%rcx
lea    0xe47(%rip),%rdx
call   1040 <snprintf@plt>
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
cmpb   $0x0,(%rax)
je     1205 <guess_script_title_from_first_line+0xd5>
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0xa,%eax
jne    11ef <guess_script_title_from_first_line+0xbf>
mov    -0x20(%rbp),%rax
movb   $0x0,(%rax)
jmp    1205 <guess_script_title_from_first_line+0xd5>
jmp    11f4 <guess_script_title_from_first_line+0xc4>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    11c6 <guess_script_title_from_first_line+0x96>
mov    -0x10(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x38(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
movsbl (%rax),%edi
call   1050 <isspace@plt>
mov    %rax,%rcx
mov    $0x1,%al
cmp    $0x0,%rcx
mov    %al,-0x39(%rbp)
jne    126d <guess_script_title_from_first_line+0x13d>
mov    -0x28(%rbp),%rax
movsbl (%rax),%ecx
mov    $0x1,%al
cmp    $0x2f,%ecx
mov    %al,-0x39(%rbp)
je     126d <guess_script_title_from_first_line+0x13d>
mov    -0x28(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2a,%eax
sete   %al
mov    %al,-0x39(%rbp)
mov    -0x39(%rbp),%al
test   $0x1,%al
jne    127d <guess_script_title_from_first_line+0x14d>
jmp    128e <guess_script_title_from_first_line+0x15e>
mov    -0x28(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x28(%rbp)
jmp    122a <guess_script_title_from_first_line+0xfa>
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
cmp    -0x10(%rbp),%rax
jbe    12af <guess_script_title_from_first_line+0x17f>
mov    -0x28(%rbp),%rax
movb   $0x0,(%rax)
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<guess_script_title_from_first_line>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %edx,%r14d
mov    %rsi,%r15
mov    %rdi,%rbp
jmp    1154 <guess_script_title_from_first_line+0x24>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
add    $0x1,%rbp
movsbl 0x0(%rbp),%edi
call   1050 <isspace@plt>
test   %rax,%rax
jne    1150 <guess_script_title_from_first_line+0x20>
movzbl 0x0(%rbp),%eax
cmp    $0x2f,%al
je     1150 <guess_script_title_from_first_line+0x20>
cmp    $0x2a,%al
je     1150 <guess_script_title_from_first_line+0x20>
lea    0xe8b(%rip),%rdx
mov    %r15,%rdi
mov    %r14d,%esi
mov    %rbp,%rcx
call   1040 <snprintf@plt>
mov    %r15,%rax
cs nopw 0x0(%rax,%rax,1)
movzbl (%rax),%ecx
test   %cl,%cl
je     11a5 <guess_script_title_from_first_line+0x75>
cmp    $0xa,%cl
je     11a2 <guess_script_title_from_first_line+0x72>
add    $0x1,%rax
jmp    1190 <guess_script_title_from_first_line+0x60>
movb   $0x0,(%rax)
mov    %r15,%rdi
call   1030 <strlen@plt>
movslq %eax,%rbx
add    %r15,%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %rbx,%rbp
add    $0xffffffffffffffff,%rbx
movsbl -0x1(%rbp),%edi
call   1050 <isspace@plt>
test   %rax,%rax
jne    11c0 <guess_script_title_from_first_line+0x90>
movzbl -0x1(%rbp),%eax
cmp    $0x2a,%al
je     11c0 <guess_script_title_from_first_line+0x90>
cmp    $0x2f,%al
je     11c0 <guess_script_title_from_first_line+0x90>
cmp    %r15,%rbp
jbe    11ea <guess_script_title_from_first_line+0xba>
movb   $0x0,0x0(%rbp)
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

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