#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*/ free(char *);
char *malloc(int);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ snprintf(char *, int, char *, char const *);
int strlen(char const *);
scalar_t__ system(char *);
void get_strings(char const *in) {
  char *cmd;
  int len = strlen("strings ") + strlen(in) + 1;
  cmd = malloc(len);
  snprintf(cmd, len, "strings %s", in);
  if (system(cmd))
    printf("something went wrong running %s.\n", cmd);
  free(cmd);
}


x86 assembly (clang, -O0):
<get_strings>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
lea    0xe8d(%rip),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%eax
add    %ecx,%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%edi
call   1080 <malloc@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x8(%rbp),%rcx
lea    0xe5a(%rip),%rdx
call   1070 <snprintf@plt>
mov    -0x10(%rbp),%rdi
call   1050 <system@plt>
cmp    $0x0,%rax
je     11d7 <get_strings+0x77>
mov    -0x10(%rbp),%rsi
lea    0xe42(%rip),%rdi
call   1060 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_strings>:
push   %rbp
push   %r14
push   %rbx
mov    %rdi,%r14
lea    0xe92(%rip),%rdi
call   1040 <strlen@plt>
mov    %eax,%ebx
mov    %r14,%rdi
call   1040 <strlen@plt>
lea    (%rbx,%rax,1),%ebp
add    $0x1,%ebp
mov    %ebp,%edi
call   1080 <malloc@plt>
mov    %rax,%rbx
lea    0xe75(%rip),%rdx
mov    %rax,%rdi
mov    %ebp,%esi
mov    %r14,%rcx
call   1070 <snprintf@plt>
mov    %rbx,%rdi
call   1050 <system@plt>
test   %rax,%rax
je     11bd <get_strings+0x5d>
lea    0xe5f(%rip),%rdi
mov    %rbx,%rsi
call   1060 <printf@plt>
mov    %rbx,%rdi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1030 <free@plt>

LLVM IR (-O0):
@.str = [9 x i8] c"strings \00"
@.str.1 = [11 x i8] c"strings %s\00"
@.str.2 = [34 x i8] c"something went wrong running %s.\0A\00"
define void @get_strings(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i32
store i8* %0, i8** %2
%5 = call i32 @strlen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
%6 = load i8*, i8** %2
%7 = call i32 @strlen(i8* %6)
%8 = add nsw i32 %5, %7
%9 = add nsw i32 %8, 1
store i32 %9, i32* %4
%10 = load i32, i32* %4
%11 = call i8* @malloc(i32 %10)
store i8* %11, i8** %3
%12 = load i8*, i8** %3
%13 = load i32, i32* %4
%14 = load i8*, i8** %2
%15 = call i32 @snprintf(i8* %12, i32 %13, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8* %14)
%16 = load i8*, i8** %3
%17 = call i64 @system(i8* %16)
%18 = icmp ne i64 %17, 0
br i1 %18, label %19, label %22
19: ; preds = %1
%20 = load i8*, i8** %3
%21 = call i32 @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.2, i64 0, i64 0), i8* %20)
br label %22
22: ; preds = %19, %1
%23 = load i8*, i8** %3
%24 = call i32 @free(i8* %23)
ret void
}

LLVM IR (-O2):
@.str = [9 x i8] c"strings \00"
@.str.1 = [11 x i8] c"strings %s\00"
@.str.2 = [34 x i8] c"something went wrong running %s.\0A\00"
define void @get_strings(i8* %0) {
%2 = tail call i32 @strlen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
%3 = tail call i32 @strlen(i8* %0)
%4 = add i32 %2, 1
%5 = add i32 %4, %3
%6 = tail call i8* @malloc(i32 %5)
%7 = tail call i32 @snprintf(i8* %6, i32 %5, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8* %0)
%8 = tail call i64 @system(i8* %6)
%9 = icmp eq i64 %8, 0
br i1 %9, label %12, label %10
10: ; preds = %1
%11 = tail call i32 @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.2, i64 0, i64 0), i8* %6)
br label %12
12: ; preds = %10, %1
%13 = tail call i32 @free(i8* %6)
ret void
}