#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 */
char *concat(char *, char *);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, long, char *);
scalar_t__ getpid();
void print_status(char *filename, char *status) {
  char *filelck = concat(filename, ".lck");
  FILE *fd = fopen(filelck, "w");
  fprintf(fd, "%ld %s", (long)getpid(), status);
  fclose(fd);
}


x86 assembly (clang, -O0):
<print_status>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe95(%rip),%rsi
call   1050 <concat@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xe86(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    $0x0,%al
call   1030 <getpid@plt>
mov    -0x28(%rbp),%rdi
mov    %rax,%rdx
mov    -0x10(%rbp),%rcx
lea    0xe5e(%rip),%rsi
call   1060 <fprintf@plt>
mov    -0x20(%rbp),%rdi
call   1040 <fclose@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_status>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
lea    0xea2(%rip),%rsi
call   1050 <concat@plt>
lea    0xe9b(%rip),%rsi
mov    %rax,%rdi
call   1070 <fopen@plt>
mov    %rax,%rbx
xor    %eax,%eax
call   1030 <getpid@plt>
lea    0xe84(%rip),%rsi
mov    %rbx,%rdi
mov    %rax,%rdx
mov    %r14,%rcx
call   1060 <fprintf@plt>
mov    %rbx,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1040 <fclose@plt>

LLVM IR (-O0):
@.str = [5 x i8] c".lck\00"
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [7 x i8] c"%ld %s\00"
define void @print_status(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32*
store i8* %0, i8** %3
store i8* %1, i8** %4
%7 = load i8*, i8** %3
%8 = call i8* @concat(i8* %7, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
store i8* %8, i8** %5
%9 = load i8*, i8** %5
%10 = call i32* @fopen(i8* %9, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %10, i32** %6
%11 = load i32*, i32** %6
%12 = call i64 (...) @getpid()
%13 = load i8*, i8** %4
%14 = call i32 @fprintf(i32* %11, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i64 %12, i8* %13)
%15 = load i32*, i32** %6
%16 = call i32 @fclose(i32* %15)
ret void
}

LLVM IR (-O2):
@.str = [5 x i8] c".lck\00"
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [7 x i8] c"%ld %s\00"
define void @print_status(i8* %0, i8* %1) {
%3 = tail call i8* @concat(i8* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%4 = tail call i32* @fopen(i8* %3, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%5 = tail call i64 (...) @getpid()
%6 = tail call i32 @fprintf(i32* %4, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i64 %5, i8* %1)
%7 = tail call i32 @fclose(i32* %4)
ret void
}