#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 *);
char *get_arg(int *, char *);
int /*<<< orphan*/ reset_args();
int strlen(char *);
char *strrchr(char *, char);
void AddOsAndCs(FILE *makefile) {
  char *arg, ch;
  int flag = 0;
  char *eop;
  reset_args();
  arg = get_arg(&flag, &ch);
  while ((arg = get_arg(&flag, &ch)) != NULL) {
    if (flag) {
    } else {
      if (arg[(strlen(arg) - 2)] == '.') {
        if (arg[(strlen(arg) - 1)] == 'c') {
          arg[(strlen(arg) - 1)] = 'o';
          eop = strrchr(arg, '/');
          if (eop != NULL) {
            eop++;
            fprintf(makefile, " \\\n\t%s", eop);
            arg[(strlen(arg) - 1)] = 'c';
          } else {
            fprintf(makefile, " \\\n\t%s", arg);
          }
        } else if (arg[(strlen(arg) - 1)] == 'o') {
          fprintf(makefile, " \\\n\t%s", arg);
        }
      }
    }
  }
}


x86 assembly (clang, -O0):
<AddOsAndCs>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0x18(%rbp)
mov    $0x0,%al
call   1070 <reset_args@plt>
lea    -0x18(%rbp),%rdi
lea    -0x11(%rbp),%rsi
call   1050 <get_arg@plt>
mov    %rax,-0x10(%rbp)
lea    -0x18(%rbp),%rdi
lea    -0x11(%rbp),%rsi
call   1050 <get_arg@plt>
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
je     12e8 <AddOsAndCs+0x198>
cmpl   $0x0,-0x18(%rbp)
je     11a5 <AddOsAndCs+0x55>
jmp    12e3 <AddOsAndCs+0x193>
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x28(%rbp),%rax
sub    $0x2,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x2e,%eax
jne    12de <AddOsAndCs+0x18e>
mov    -0x10(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x30(%rbp),%rax
sub    $0x1,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x63,%eax
jne    1296 <AddOsAndCs+0x146>
mov    -0x10(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x38(%rbp),%rax
sub    $0x1,%ecx
movslq %ecx,%rcx
movb   $0x6f,(%rax,%rcx,1)
mov    -0x10(%rbp),%rdi
mov    $0x2f,%esi
call   1040 <strrchr@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     127d <AddOsAndCs+0x12d>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x20(%rbp),%rdx
lea    0xdae(%rip),%rsi
call   1060 <fprintf@plt>
mov    -0x10(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x40(%rbp),%rax
sub    $0x1,%ecx
movslq %ecx,%rcx
movb   $0x63,(%rax,%rcx,1)
jmp    1291 <AddOsAndCs+0x141>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rdx
lea    0xd74(%rip),%rsi
call   1060 <fprintf@plt>
jmp    12d9 <AddOsAndCs+0x189>
mov    -0x10(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x48(%rbp),%rax
sub    $0x1,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x6f,%eax
jne    12d4 <AddOsAndCs+0x184>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rdx
lea    0xd31(%rip),%rsi
call   1060 <fprintf@plt>
jmp    12d9 <AddOsAndCs+0x189>
jmp    12de <AddOsAndCs+0x18e>
jmp    12e3 <AddOsAndCs+0x193>
jmp    117b <AddOsAndCs+0x2b>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<AddOsAndCs>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdi,%r15
movl   $0x0,0x4(%rsp)
xor    %eax,%eax
call   1070 <reset_args@plt>
lea    0x4(%rsp),%rbx
lea    0x3(%rsp),%r14
mov    %rbx,%rdi
mov    %r14,%rsi
call   1050 <get_arg@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1050 <get_arg@plt>
test   %rax,%rax
je     125b <AddOsAndCs+0x10b>
mov    %rax,%rbx
lea    0xe60(%rip),%r14
lea    0x4(%rsp),%r12
lea    0x3(%rsp),%r13
jmp    11d7 <AddOsAndCs+0x87>
mov    %r15,%rdi
mov    %r14,%rsi
mov    %rbx,%rdx
call   1060 <fprintf@plt>
nopw   0x0(%rax,%rax,1)
mov    %r12,%rdi
mov    %r13,%rsi
call   1050 <get_arg@plt>
mov    %rax,%rbx
test   %rax,%rax
je     125b <AddOsAndCs+0x10b>
cmpl   $0x0,0x4(%rsp)
jne    11c0 <AddOsAndCs+0x70>
mov    %rbx,%rdi
call   1030 <strlen@plt>
cltq
cmpb   $0x2e,-0x2(%rax,%rbx,1)
jne    11c0 <AddOsAndCs+0x70>
mov    %rbx,%rdi
call   1030 <strlen@plt>
cltq
movzbl -0x1(%rax,%rbx,1),%ebp
mov    %rbx,%rdi
call   1030 <strlen@plt>
cltq
cmp    $0x63,%bpl
jne    124b <AddOsAndCs+0xfb>
movb   $0x6f,-0x1(%rbx,%rax,1)
mov    %rbx,%rdi
mov    $0x2f,%esi
call   1040 <strrchr@plt>
test   %rax,%rax
je     11ac <AddOsAndCs+0x5c>
add    $0x1,%rax
mov    %r15,%rdi
mov    %r14,%rsi
mov    %rax,%rdx
call   1060 <fprintf@plt>
mov    %rbx,%rdi
call   1030 <strlen@plt>
cltq
movb   $0x63,-0x1(%rax,%rbx,1)
jmp    11c0 <AddOsAndCs+0x70>
cmpb   $0x6f,-0x1(%rbx,%rax,1)
je     11ac <AddOsAndCs+0x5c>
jmp    11c0 <AddOsAndCs+0x70>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [7 x i8] c" \\\0A\09%s\00"
define void @AddOsAndCs(i32* nocapture %0) {
%2 = alloca i8
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
store i32 0, i32* %3
%5 = tail call i32 (...) @reset_args()
%6 = call i8* @get_arg(i32* %3, i8* %2)
%7 = call i8* @get_arg(i32* %3, i8* %2)
%8 = icmp eq i8* %7, null
br i1 %8, label %51, label %9
9: ; preds = %1, %48
%10 = phi i8* [ %49, %48 ], [ %7, %1 ]
%11 = load i32, i32* %3
%12 = icmp eq i32 %11, 0
br i1 %12, label %13, label %48
13: ; preds = %9
%14 = call i32 @strlen(i8* %10)
%15 = add nsw i32 %14, -2
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds i8, i8* %10, i64 %16
%18 = load i8, i8* %17
%19 = icmp eq i8 %18, 46
br i1 %19, label %20, label %48
20: ; preds = %13
%21 = call i32 @strlen(i8* %10)
%22 = add nsw i32 %21, -1
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds i8, i8* %10, i64 %23
%25 = load i8, i8* %24
%26 = icmp eq i8 %25, 99
%27 = call i32 @strlen(i8* %10)
%28 = add nsw i32 %27, -1
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds i8, i8* %10, i64 %29
br i1 %26, label %31, label %43
31: ; preds = %20
store i8 111, i8* %30
%32 = call i8* @strrchr(i8* %10, i8 signext 47)
%33 = icmp eq i8* %32, null
br i1 %33, label %41, label %34
34: ; preds = %31
%35 = getelementptr inbounds i8, i8* %32, i64 1
%36 = call i32 @fprintf(i32* %0, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* %35)
%37 = call i32 @strlen(i8* %10)
%38 = add nsw i32 %37, -1
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds i8, i8* %10, i64 %39
store i8 99, i8* %40
br label %48
41: ; preds = %31
%42 = call i32 @fprintf(i32* %0, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* %10)
br label %48
43: ; preds = %20
%44 = load i8, i8* %30
%45 = icmp eq i8 %44, 111
br i1 %45, label %46, label %48
46: ; preds = %43
%47 = call i32 @fprintf(i32* %0, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* %10)
br label %48
48: ; preds = %13, %43, %46, %34, %41, %9
%49 = call i8* @get_arg(i32* %3, i8* %2)
%50 = icmp eq i8* %49, null
br i1 %50, label %51, label %9
51: ; preds = %48, %1
ret void
}