#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*/ close_the_file(int /*<<< orphan*/ *, char *);
int /*<<< orphan*/ *fopen(char *, char *);
int getpid();
int /*<<< orphan*/ print_warning(int /*<<< orphan*/ *, char *, char *);
int /*<<< orphan*/ sprintf(char *, char *, ...);
int system(char *);
int add_warning(char *fname) {
  FILE *fp;
  char tempfile[512];
  char tempfile1[512];
  char commline[7000];
  sprintf(tempfile, "regtmp1%d", getpid());
  sprintf(tempfile1, "regtmp2%d", getpid());
  if ((fp = fopen(tempfile, "w")) == NULL)
    return (1);
  print_warning(fp, tempfile, "");
  close_the_file(fp, "");
  sprintf(commline, "%s %s %s > %s ; %s %s %s ; %s %s ", "/bin/cat", tempfile,
          fname, tempfile1, "/bin/mv", tempfile1, fname, "/bin/rm", tempfile);
  return (system(commline));
}


x86 assembly (clang, -O0):
<add_warning>:
push   %rbp
mov    %rsp,%rbp
push   %r14
push   %rbx
sub    $0x1fc0,%rsp
mov    %rdi,-0x20(%rbp)
lea    -0x230(%rbp),%rax
mov    %rax,-0x1fa0(%rbp)
mov    $0x0,%al
call   1030 <getpid@plt>
mov    -0x1fa0(%rbp),%rdi
mov    %eax,%edx
lea    0xe69(%rip),%rsi
mov    $0x0,%al
call   1080 <sprintf@plt>
lea    -0x430(%rbp),%rax
mov    %rax,-0x1f98(%rbp)
mov    $0x0,%al
call   1030 <getpid@plt>
mov    -0x1f98(%rbp),%rdi
mov    %eax,%edx
lea    0xe47(%rip),%rsi
mov    $0x0,%al
call   1080 <sprintf@plt>
lea    -0x230(%rbp),%rdi
lea    0xe3c(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x28(%rbp)
cmp    $0x0,%rax
jne    11f7 <add_warning+0x97>
movl   $0x1,-0x14(%rbp)
jmp    1293 <add_warning+0x133>
mov    -0x28(%rbp),%rdi
lea    -0x230(%rbp),%rsi
lea    0xe2e(%rip),%rdx
call   1040 <print_warning@plt>
mov    -0x28(%rbp),%rdi
lea    0xe1e(%rip),%rsi
call   1060 <close_the_file@plt>
lea    -0x1f90(%rbp),%rdi
lea    -0x230(%rbp),%rcx
mov    -0x20(%rbp),%r8
lea    -0x430(%rbp),%r9
lea    -0x430(%rbp),%rbx
mov    -0x20(%rbp),%r11
lea    -0x230(%rbp),%rax
lea    0xdc6(%rip),%rsi
lea    0xde1(%rip),%rdx
lea    0xde3(%rip),%r14
lea    0xde4(%rip),%r10
mov    %r14,(%rsp)
mov    %rbx,0x8(%rsp)
mov    %r11,0x10(%rsp)
mov    %r10,0x18(%rsp)
mov    %rax,0x20(%rsp)
mov    $0x0,%al
call   1080 <sprintf@plt>
lea    -0x1f90(%rbp),%rdi
call   1050 <system@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1fc0,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

x86 assembly (clang, -O2):
<add_warning>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x1f60,%rsp
mov    %rdi,%r14
xor    %eax,%eax
call   1030 <getpid@plt>
lea    0xe7f(%rip),%rsi
lea    0x200(%rsp),%r12
mov    %r12,%rdi
mov    %eax,%edx
xor    %eax,%eax
call   1080 <sprintf@plt>
xor    %eax,%eax
call   1030 <getpid@plt>
lea    0xe67(%rip),%rsi
mov    %rsp,%r15
mov    %r15,%rdi
mov    %eax,%edx
xor    %eax,%eax
call   1080 <sprintf@plt>
lea    0xe5b(%rip),%rsi
mov    %r12,%rdi
call   1070 <fopen@plt>
test   %rax,%rax
je     123c <add_warning+0xdc>
mov    %rax,%rbx
lea    0xe67(%rip),%r13
mov    %rax,%rdi
mov    %r12,%rsi
mov    %r13,%rdx
call   1040 <print_warning@plt>
mov    %rbx,%rdi
mov    %r13,%rsi
call   1060 <close_the_file@plt>
sub    $0x8,%rsp
lea    0xe55(%rip),%r10
lea    0xe46(%rip),%r11
lea    0xe14(%rip),%rsi
lea    0xe2f(%rip),%rdx
lea    0x408(%rsp),%rbx
mov    %rbx,%rdi
mov    %r12,%rcx
mov    %r14,%r8
mov    %r15,%r9
xor    %eax,%eax
push   %r12
push   %r10
push   %r14
push   %r15
push   %r11
call   1080 <sprintf@plt>
add    $0x30,%rsp
mov    %rbx,%rdi
call   1050 <system@plt>
jmp    1241 <add_warning+0xe1>
mov    $0x1,%eax
add    $0x1f60,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [10 x i8] c"regtmp1%d\00"
@.str.1 = [10 x i8] c"regtmp2%d\00"
@.str.2 = [2 x i8] c"w\00"
@.str.3 = [1 x i8] zeroinitializer
@.str.4 = [34 x i8] c"%s %s %s > %s ; %s %s %s ; %s %s \00"
@.str.5 = [9 x i8] c"/bin/cat\00"
@.str.6 = [8 x i8] c"/bin/mv\00"
@.str.7 = [8 x i8] c"/bin/rm\00"
define i32 @add_warning(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32*
%5 = alloca [512 x i8]
%6 = alloca [512 x i8]
%7 = alloca [7000 x i8]
store i8* %0, i8** %3
%8 = getelementptr inbounds [512 x i8], [512 x i8]* %5, i64 0, i64 0
%9 = call i32 (...) @getpid()
%10 = call i32 (i8*, i8*, ...) @sprintf(i8* %8, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 %9)
%11 = getelementptr inbounds [512 x i8], [512 x i8]* %6, i64 0, i64 0
%12 = call i32 (...) @getpid()
%13 = call i32 (i8*, i8*, ...) @sprintf(i8* %11, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i32 %12)
%14 = getelementptr inbounds [512 x i8], [512 x i8]* %5, i64 0, i64 0
%15 = call i32* @fopen(i8* %14, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32* %15, i32** %4
%16 = icmp eq i32* %15, null
br i1 %16, label %17, label %18
17: ; preds = %1
store i32 1, i32* %2
br label %34
18: ; preds = %1
%19 = load i32*, i32** %4
%20 = getelementptr inbounds [512 x i8], [512 x i8]* %5, i64 0, i64 0
%21 = call i32 @print_warning(i32* %19, i8* %20, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.3, i64 0, i64 0))
%22 = load i32*, i32** %4
%23 = call i32 @close_the_file(i32* %22, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.3, i64 0, i64 0))
%24 = getelementptr inbounds [7000 x i8], [7000 x i8]* %7, i64 0, i64 0
%25 = getelementptr inbounds [512 x i8], [512 x i8]* %5, i64 0, i64 0
%26 = load i8*, i8** %3
%27 = getelementptr inbounds [512 x i8], [512 x i8]* %6, i64 0, i64 0
%28 = getelementptr inbounds [512 x i8], [512 x i8]* %6, i64 0, i64 0
%29 = load i8*, i8** %3
%30 = getelementptr inbounds [512 x i8], [512 x i8]* %5, i64 0, i64 0
%31 = call i32 (i8*, i8*, ...) @sprintf(i8* %24, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0), i8* %25, i8* %26, i8* %27, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.6, i64 0, i64 0), i8* %28, i8* %29, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.7, i64 0, i64 0), i8* %30)
%32 = getelementptr inbounds [7000 x i8], [7000 x i8]* %7, i64 0, i64 0
%33 = call i32 @system(i8* %32)
store i32 %33, i32* %2
br label %34
34: ; preds = %18, %17
%35 = load i32, i32* %2
ret i32 %35
}

LLVM IR (-O2):
@.str = [10 x i8] c"regtmp1%d\00"
@.str.1 = [10 x i8] c"regtmp2%d\00"
@.str.2 = [2 x i8] c"w\00"
@.str.3 = [1 x i8] zeroinitializer
@.str.4 = [34 x i8] c"%s %s %s > %s ; %s %s %s ; %s %s \00"
@.str.5 = [9 x i8] c"/bin/cat\00"
@.str.6 = [8 x i8] c"/bin/mv\00"
@.str.7 = [8 x i8] c"/bin/rm\00"
define i32 @add_warning(i8* %0) {
%2 = alloca [512 x i8]
%3 = alloca [512 x i8]
%4 = alloca [7000 x i8]
%5 = getelementptr inbounds [512 x i8], [512 x i8]* %2, i64 0, i64 0
%6 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 0
%7 = getelementptr inbounds [7000 x i8], [7000 x i8]* %4, i64 0, i64 0
%8 = tail call i32 (...) @getpid()
%9 = call i32 (i8*, i8*, ...) @sprintf(i8* %5, i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 %8)
%10 = tail call i32 (...) @getpid()
%11 = call i32 (i8*, i8*, ...) @sprintf(i8* %6, i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i32 %10)
%12 = call i32* @fopen(i8* %5, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%13 = icmp eq i32* %12, null
br i1 %13, label %19, label %14
14: ; preds = %1
%15 = call i32 @print_warning(i32* %12, i8* %5, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.3, i64 0, i64 0))
%16 = call i32 @close_the_file(i32* %12, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.3, i64 0, i64 0))
%17 = call i32 (i8*, i8*, ...) @sprintf(i8* %7, i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0), i8* %5, i8* %0, i8* %6, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.6, i64 0, i64 0), i8* %6, i8* %0, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.7, i64 0, i64 0), i8* %5)
%18 = call i32 @system(i8* %7)
br label %19
19: ; preds = %1, %14
%20 = phi i32 [ %18, %14 ], [ 1, %1 ]
ret i32 %20
}