#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 *config_get(char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
void add_smbd_global(FILE *fp) {
  char *p;
  fprintf(fp, "[global]\n");
  p = config_get("usb_workGroup");
  if (*p == '\0')
    p = "Workgroup";
  fprintf(fp, "  workgroup = %s\n", p);
  p = config_get("Readyshare_name");
  if (*p == '\0')
    p = config_get("usb_deviceName");
  fprintf(fp, "  netbios name = %s\n", p);
  fprintf(fp, "  bind interfaces only = yes\n"
              "  server string = "
              "NETGEAR R7800"
              "\n"
              "  unix charset = UTF8\n"
              "  display charset = UTF8\n"
              "  log file = /var/log.samba\n"
              "  log level = 0\n"
              "  max log size = 5\n"
              "  obey pam restrictions = no\n"
              "  disable spoolss = yes\n"
              "  strict allocate = no\n"
              "  host msdfs = no\n"
              "  security = user\n"
              "  map to guest = Bad User\n"
              "  encrypt passwords = yes\n"
              "  pam password change = no\n"
              "  null passwords = yes\n"
              "  smb encrypt = disabled\n"
              "  max protocol = SMB2\n"
              "  passdb backend = smbpasswd\n"
              "  smb passwd file = /etc/samba/smbpasswd\n"
              "  enable core files = no\n"
              "  deadtime = 30\n"
              "  force directory mode = 0777\n"
              "  force create mode = 0777\n"
              "  use sendfile = yes\n"
              "  map archive = no\n"
              "  map hidden = no\n"
              "  map read only = no\n"
              "  map system = no\n"
              "  store dos attributes = no\n"
              "  dos filemode = yes\n"
              "  oplocks = yes\n"
              "  level2 oplocks = yes\n"
              "  kernel oplocks = no\n"
              "  wide links = no\n"
              "  min receivefile size = 16384\n"
              "  socket options = IPTOS_LOWDELAY TCP_NODELAY SO_KEEPALIVE "
              "SO_RCVBUF=131072 SO_SNDBUF=131072\n"
              "\n");
}


x86 assembly (clang, -O0):
<add_smbd_global>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xec9(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
lea    0xec5(%rip),%rdi
call   1030 <config_get@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    1169 <add_smbd_global+0x49>
lea    0xeb3(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rdx
lea    0xeaa(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
lea    0xeae(%rip),%rdi
call   1030 <config_get@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    11af <add_smbd_global+0x8f>
lea    0xe9e(%rip),%rdi
call   1030 <config_get@plt>
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rdx
lea    0xe95(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x8(%rbp),%rdi
lea    0xe98(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<add_smbd_global>:
push   %rbx
mov    %rdi,%rbx
lea    0xec5(%rip),%rdi
mov    $0x9,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1050 <fwrite@plt>
lea    0xeb6(%rip),%rdi
call   1030 <config_get@plt>
cmpb   $0x0,(%rax)
lea    0xeb5(%rip),%rdx
cmovne %rax,%rdx
lea    0xeb4(%rip),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <fprintf@plt>
lea    0xeb5(%rip),%rdi
call   1030 <config_get@plt>
cmpb   $0x0,(%rax)
jne    1195 <add_smbd_global+0x65>
lea    0xeb4(%rip),%rdi
call   1030 <config_get@plt>
lea    0xeb7(%rip),%rsi
mov    %rbx,%rdi
mov    %rax,%rdx
xor    %eax,%eax
call   1040 <fprintf@plt>
lea    0xeb8(%rip),%rdi
mov    $0x3b6,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
pop    %rbx
jmp    1050 <fwrite@plt>

LLVM IR (-O0):
@.str = [10 x i8] c"[global]\0A\00"
@.str.1 = [14 x i8] c"usb_workGroup\00"
@.str.2 = [10 x i8] c"Workgroup\00"
@.str.3 = [18 x i8] c" workgroup = %s\0A\00"
@.str.4 = [16 x i8] c"Readyshare_name\00"
@.str.5 = [15 x i8] c"usb_deviceName\00"
@.str.6 = [21 x i8] c" netbios name = %s\0A\00"
@.str.7 = [951 x i8] c" bind interfaces only = yes\0A server string = NETGEAR R7800\0A unix charset = UTF8\0A display charset = UTF8\0A log file = /var/log.samba\0A log level = 0\0A max log size = 5\0A obey pam restrictions = no\0A disable spoolss = yes\0A strict allocate = no\0A host msdfs = no\0A security = user\0A map to guest = Bad User\0A encrypt passwords = yes\0A pam password change = no\0A null passwords = yes\0A smb encrypt = disabled\0A max protocol = SMB2\0A passdb backend = smbpasswd\0A smb passwd file = /etc/samba/smbpasswd\0A enable core files = no\0A deadtime = 30\0A force directory mode = 0777\0A force create mode = 0777\0A use sendfile = yes\0A map archive = no\0A map hidden = no\0A map read only = no\0A map system = no\0A store dos attributes = no\0A dos filemode = yes\0A oplocks = yes\0A level2 oplocks = yes\0A kernel oplocks = no\0A wide links = no\0A min receivefile size = 16384\0A socket options = IPTOS_LOWDELAY TCP_NODELAY SO_KEEPALIVE SO_RCVBUF=131072 SO_SNDBUF=131072\0A\0A\00"
define void @add_smbd_global(i32* %0) {
%2 = alloca i32*
%3 = alloca i8*
store i32* %0, i32** %2
%4 = load i32*, i32** %2
%5 = call i32 (i32*, i8*, ...) @fprintf(i32* %4, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%6 = call i8* @config_get(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
store i8* %6, i8** %3
%7 = load i8*, i8** %3
%8 = load i8, i8* %7
%9 = sext i8 %8 to i32
%10 = icmp eq i32 %9, 0
br i1 %10, label %11, label %12
11: ; preds = %1
store i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8** %3
br label %12
12: ; preds = %11, %1
%13 = load i32*, i32** %2
%14 = load i8*, i8** %3
%15 = call i32 (i32*, i8*, ...) @fprintf(i32* %13, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0), i8* %14)
%16 = call i8* @config_get(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0))
store i8* %16, i8** %3
%17 = load i8*, i8** %3
%18 = load i8, i8* %17
%19 = sext i8 %18 to i32
%20 = icmp eq i32 %19, 0
br i1 %20, label %21, label %23
21: ; preds = %12
%22 = call i8* @config_get(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0))
store i8* %22, i8** %3
br label %23
23: ; preds = %21, %12
%24 = load i32*, i32** %2
%25 = load i8*, i8** %3
%26 = call i32 (i32*, i8*, ...) @fprintf(i32* %24, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.6, i64 0, i64 0), i8* %25)
%27 = load i32*, i32** %2
%28 = call i32 (i32*, i8*, ...) @fprintf(i32* %27, i8* getelementptr inbounds ([951 x i8], [951 x i8]* @.str.7, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [10 x i8] c"[global]\0A\00"
@.str.1 = [14 x i8] c"usb_workGroup\00"
@.str.2 = [10 x i8] c"Workgroup\00"
@.str.3 = [18 x i8] c" workgroup = %s\0A\00"
@.str.4 = [16 x i8] c"Readyshare_name\00"
@.str.5 = [15 x i8] c"usb_deviceName\00"
@.str.6 = [21 x i8] c" netbios name = %s\0A\00"
@.str.7 = [951 x i8] c" bind interfaces only = yes\0A server string = NETGEAR R7800\0A unix charset = UTF8\0A display charset = UTF8\0A log file = /var/log.samba\0A log level = 0\0A max log size = 5\0A obey pam restrictions = no\0A disable spoolss = yes\0A strict allocate = no\0A host msdfs = no\0A security = user\0A map to guest = Bad User\0A encrypt passwords = yes\0A pam password change = no\0A null passwords = yes\0A smb encrypt = disabled\0A max protocol = SMB2\0A passdb backend = smbpasswd\0A smb passwd file = /etc/samba/smbpasswd\0A enable core files = no\0A deadtime = 30\0A force directory mode = 0777\0A force create mode = 0777\0A use sendfile = yes\0A map archive = no\0A map hidden = no\0A map read only = no\0A map system = no\0A store dos attributes = no\0A dos filemode = yes\0A oplocks = yes\0A level2 oplocks = yes\0A kernel oplocks = no\0A wide links = no\0A min receivefile size = 16384\0A socket options = IPTOS_LOWDELAY TCP_NODELAY SO_KEEPALIVE SO_RCVBUF=131072 SO_SNDBUF=131072\0A\0A\00"
define void @add_smbd_global(i32* nocapture %0) {
%2 = tail call i64 @fwrite(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i64 9, i64 1, i32* %0)
%3 = tail call i8* @config_get(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
%4 = load i8, i8* %3
%5 = icmp eq i8 %4, 0
%6 = select i1 %5, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8* %3
%7 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0), i8* %6)
%8 = tail call i8* @config_get(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0))
%9 = load i8, i8* %8
%10 = icmp eq i8 %9, 0
br i1 %10, label %11, label %13
11: ; preds = %1
%12 = tail call i8* @config_get(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0))
br label %13
13: ; preds = %11, %1
%14 = phi i8* [ %12, %11 ], [ %8, %1 ]
%15 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.6, i64 0, i64 0), i8* %14)
%16 = tail call i64 @fwrite(i8* getelementptr inbounds ([951 x i8], [951 x i8]* @.str.7, i64 0, i64 0), i64 950, i64 1, i32* %0)
ret void
}