#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*/ *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, char *, char *);
int /*<<< orphan*/ strip_line(char *);
void save_str(FILE *f, FILE *f2, char *keyword) {
  char buf[512];
  if (fgets(buf, 512, f) == NULL)
    return;
  strip_line(buf);
  if (*buf)
    fprintf(f2, "%s=%s\n", keyword, buf);
}


x86 assembly (clang, -O0):
<save_str>:
push   %rbp
mov    %rsp,%rbp
sub    $0x220,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
lea    -0x220(%rbp),%rdi
mov    -0x8(%rbp),%rdx
mov    $0x200,%esi
call   1030 <fgets@plt>
cmp    $0x0,%rax
jne    116b <save_str+0x3b>
jmp    119f <save_str+0x6f>
lea    -0x220(%rbp),%rdi
call   1050 <strip_line@plt>
cmpb   $0x0,-0x220(%rbp)
je     119f <save_str+0x6f>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rdx
lea    -0x220(%rbp),%rcx
lea    0xe66(%rip),%rsi
call   1040 <fprintf@plt>
add    $0x220,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<save_str>:
push   %r14
push   %rbx
sub    $0x208,%rsp
mov    %rdx,%r14
mov    %rsi,%rbx
mov    %rdi,%rdx
mov    %rsp,%rdi
mov    $0x200,%esi
call   1030 <fgets@plt>
test   %rax,%rax
je     1178 <save_str+0x48>
mov    %rsp,%rdi
call   1050 <strip_line@plt>
cmpb   $0x0,(%rsp)
je     1178 <save_str+0x48>
lea    0xe96(%rip),%rsi
mov    %rsp,%rcx
mov    %rbx,%rdi
mov    %r14,%rdx
call   1040 <fprintf@plt>
add    $0x208,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [7 x i8] c"%s=%s\0A\00"
define void @save_str(i32* %0, i32* %1, i8* %2) {
%4 = alloca i32*
%5 = alloca i32*
%6 = alloca i8*
%7 = alloca [512 x i8]
store i32* %0, i32** %4
store i32* %1, i32** %5
store i8* %2, i8** %6
%8 = getelementptr inbounds [512 x i8], [512 x i8]* %7, i64 0, i64 0
%9 = load i32*, i32** %4
%10 = call i32* @fgets(i8* %8, i32 512, i32* %9)
%11 = icmp eq i32* %10, null
br i1 %11, label %12, label %13
12: ; preds = %3
br label %24
13: ; preds = %3
%14 = getelementptr inbounds [512 x i8], [512 x i8]* %7, i64 0, i64 0
%15 = call i32 @strip_line(i8* %14)
%16 = getelementptr inbounds [512 x i8], [512 x i8]* %7, i64 0, i64 0
%17 = load i8, i8* %16
%18 = icmp ne i8 %17, 0
br i1 %18, label %19, label %24
19: ; preds = %13
%20 = load i32*, i32** %5
%21 = load i8*, i8** %6
%22 = getelementptr inbounds [512 x i8], [512 x i8]* %7, i64 0, i64 0
%23 = call i32 @fprintf(i32* %20, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* %21, i8* %22)
br label %24
24: ; preds = %12, %19, %13
ret void
}

LLVM IR (-O2):
@.str = [7 x i8] c"%s=%s\0A\00"
define void @save_str(i32* nocapture %0, i32* nocapture %1, i8* %2) {
%4 = alloca [512 x i8]
%5 = getelementptr inbounds [512 x i8], [512 x i8]* %4, i64 0, i64 0
%6 = call i32* @fgets(i8* %5, i32 512, i32* %0)
%7 = icmp eq i32* %6, null
br i1 %7, label %14, label %8
8: ; preds = %3
%9 = call i32 @strip_line(i8* %5)
%10 = load i8, i8* %5
%11 = icmp eq i8 %10, 0
br i1 %11, label %14, label %12
12: ; preds = %8
%13 = call i32 @fprintf(i32* %1, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* %2, i8* %5)
br label %14
14: ; preds = %8, %12, %3
ret void
}