#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*/ printf(char *, char *);
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
int getWriteToFile(int argc, char *argv[], char *name, int size) {
  int num = 0;
  for (num = 0; num != argc; ++num) {
    if (strcmp(argv[num], "-w") == 0 && num + 1 <= argc - 1) {
      if (strlen(argv[num + 1]) >= size - 1) {
        return 0;
      } else {
        strcpy(name, argv[num + 1]);
        printf("Writing to file %s\n", argv[num + 1]);
        return 1;
      }
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<getWriteToFile>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x8(%rbp),%eax
je     122c <getWriteToFile+0xec>
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xe7d(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
jne    1219 <getWriteToFile+0xd9>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    -0x8(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jg     1219 <getWriteToFile+0xd9>
mov    -0x10(%rbp),%rax
mov    -0x20(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rdi
call   1040 <strlen@plt>
mov    -0x1c(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jl     11d6 <getWriteToFile+0x96>
movl   $0x0,-0x4(%rbp)
jmp    1233 <getWriteToFile+0xf3>
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    -0x20(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rsi
call   1030 <strcpy@plt>
mov    -0x10(%rbp),%rax
mov    -0x20(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rsi
lea    0xdfb(%rip),%rdi
call   1050 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1233 <getWriteToFile+0xf3>
jmp    121e <getWriteToFile+0xde>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1164 <getWriteToFile+0x24>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getWriteToFile>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
test   %edi,%edi
je     11cc <getWriteToFile+0x8c>
mov    %ecx,%r15d
mov    %rsi,%rbx
mov    %rdx,(%rsp)
lea    -0x1(%rdi),%eax
movslq %eax,%r13
mov    %edi,%r14d
xor    %ebp,%ebp
lea    0xe95(%rip),%r12
jmp    1179 <getWriteToFile+0x39>
nopl   (%rax)
add    $0x1,%rbp
cmp    %rbp,%r14
je     11cc <getWriteToFile+0x8c>
mov    (%rbx,%rbp,8),%rdi
mov    %r12,%rsi
call   1060 <strcmp@plt>
test   %rax,%rax
jne    1170 <getWriteToFile+0x30>
cmp    %r13,%rbp
jge    1170 <getWriteToFile+0x30>
mov    0x8(%rbx,%rbp,8),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
add    $0xffffffff,%r15d
xor    %eax,%eax
cmp    %r15d,%ecx
jge    11ce <getWriteToFile+0x8e>
mov    0x8(%rbx,%rbp,8),%rsi
mov    (%rsp),%rdi
call   1030 <strcpy@plt>
mov    0x8(%rbx,%rbp,8),%rsi
lea    0xe43(%rip),%rdi
call   1050 <printf@plt>
mov    $0x1,%eax
jmp    11ce <getWriteToFile+0x8e>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"-w\00"
@.str.1 = [20 x i8] c"Writing to file %s\0A\00"
define i32 @getWriteToFile(i32 %0, i8** %1, i8* %2, i32 %3) {
%5 = alloca i32
%6 = alloca i32
%7 = alloca i8**
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i32
store i32 %0, i32* %6
store i8** %1, i8*** %7
store i8* %2, i8** %8
store i32 %3, i32* %9
store i32 0, i32* %10
store i32 0, i32* %10
br label %11
11: ; preds = %58, %4
%12 = load i32, i32* %10
%13 = load i32, i32* %6
%14 = icmp ne i32 %12, %13
br i1 %14, label %15, label %61
15: ; preds = %11
%16 = load i8**, i8*** %7
%17 = load i32, i32* %10
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds i8*, i8** %16, i64 %18
%20 = load i8*, i8** %19
%21 = call i64 @strcmp(i8* %20, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%22 = icmp eq i64 %21, 0
br i1 %22, label %23, label %57
23: ; preds = %15
%24 = load i32, i32* %10
%25 = add nsw i32 %24, 1
%26 = load i32, i32* %6
%27 = sub nsw i32 %26, 1
%28 = icmp sle i32 %25, %27
br i1 %28, label %29, label %57
29: ; preds = %23
%30 = load i8**, i8*** %7
%31 = load i32, i32* %10
%32 = add nsw i32 %31, 1
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds i8*, i8** %30, i64 %33
%35 = load i8*, i8** %34
%36 = call i32 @strlen(i8* %35)
%37 = load i32, i32* %9
%38 = sub nsw i32 %37, 1
%39 = icmp sge i32 %36, %38
br i1 %39, label %40, label %41
40: ; preds = %29
store i32 0, i32* %5
br label %62
41: ; preds = %29
%42 = load i8*, i8** %8
%43 = load i8**, i8*** %7
%44 = load i32, i32* %10
%45 = add nsw i32 %44, 1
%46 = sext i32 %45 to i64
%47 = getelementptr inbounds i8*, i8** %43, i64 %46
%48 = load i8*, i8** %47
%49 = call i32 @strcpy(i8* %42, i8* %48)
%50 = load i8**, i8*** %7
%51 = load i32, i32* %10
%52 = add nsw i32 %51, 1
%53 = sext i32 %52 to i64
%54 = getelementptr inbounds i8*, i8** %50, i64 %53
%55 = load i8*, i8** %54
%56 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i8* %55)
store i32 1, i32* %5
br label %62
57: ; preds = %23, %15
br label %58
58: ; preds = %57
%59 = load i32, i32* %10
%60 = add nsw i32 %59, 1
store i32 %60, i32* %10
br label %11
61: ; preds = %11
store i32 0, i32* %5
br label %62
62: ; preds = %61, %41, %40
%63 = load i32, i32* %5
ret i32 %63
}

LLVM IR (-O2):
@.str = [3 x i8] c"-w\00"
@.str.1 = [20 x i8] c"Writing to file %s\0A\00"
define i32 @getWriteToFile(i32 %0, i8** nocapture %1, i8* %2, i32 %3) {
%5 = icmp eq i32 %0, 0
br i1 %5, label %33, label %6
6: ; preds = %4
%7 = add nsw i32 %0, -1
%8 = sext i32 %7 to i64
%9 = zext i32 %0 to i64
br label %10
10: ; preds = %6, %31
%11 = phi i64 [ 0, %6 ], [ %18, %31 ]
%12 = getelementptr inbounds i8*, i8** %1, i64 %11
%13 = load i8*, i8** %12
%14 = tail call i64 @strcmp(i8* %13, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%15 = icmp eq i64 %14, 0
%16 = icmp slt i64 %11, %8
%17 = select i1 %15, i1 %16, i1 false
%18 = add nuw nsw i64 %11, 1
br i1 %17, label %19, label %31
19: ; preds = %10
%20 = and i64 %18, 4294967295
%21 = getelementptr inbounds i8*, i8** %1, i64 %20
%22 = load i8*, i8** %21
%23 = tail call i32 @strlen(i8* %22)
%24 = add nsw i32 %3, -1
%25 = icmp slt i32 %23, %24
br i1 %25, label %26, label %33
26: ; preds = %19
%27 = load i8*, i8** %21
%28 = tail call i32 @strcpy(i8* %2, i8* %27)
%29 = load i8*, i8** %21
%30 = tail call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i8* %29)
br label %33
31: ; preds = %10
%32 = icmp eq i64 %18, %9
br i1 %32, label %33, label %10
33: ; preds = %31, %4, %19, %26
%34 = phi i32 [ 1, %26 ], [ 0, %19 ], [ 0, %4 ], [ 0, %31 ]
ret i32 %34
}