#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(scalar_t__);
int /*<<< orphan*/ netsnmp_config(char *);
int /*<<< orphan*/ strcat(char *, char *);
char *strchr(char *, char);
int /*<<< orphan*/ strcpy(char *, char const *);
scalar_t__ strlen(char const *);
void handle_long_opt(const char *myoptarg) {
  char *cp, *cp2;
  cp = malloc(strlen(myoptarg) + 3);
  strcpy(cp, myoptarg);
  cp2 = strchr(cp, '=');
  if (!cp2 && !strchr(cp, ' ')) {
    strcat(cp, " 1");
  } else {
    if (cp2)
      *cp2 = ' ';
  }
  netsnmp_config(cp);
  free(cp);
}


x86 assembly (clang, -O0):
<handle_long_opt>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1060 <strlen@plt>
mov    %rax,%rdi
add    $0x3,%rdi
call   1080 <malloc@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1040 <strcpy@plt>
mov    -0x10(%rbp),%rdi
mov    $0x3d,%esi
call   1070 <strchr@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11ec <handle_long_opt+0x7c>
mov    -0x10(%rbp),%rdi
mov    $0x20,%esi
call   1070 <strchr@plt>
cmp    $0x0,%rax
jne    11ec <handle_long_opt+0x7c>
mov    -0x10(%rbp),%rdi
lea    0xe1e(%rip),%rsi
call   1090 <strcat@plt>
jmp    1203 <handle_long_opt+0x93>
cmpq   $0x0,-0x18(%rbp)
je     11fe <handle_long_opt+0x8e>
mov    -0x18(%rbp),%rax
movb   $0x20,(%rax)
jmp    1203 <handle_long_opt+0x93>
mov    -0x10(%rbp),%rdi
call   1050 <netsnmp_config@plt>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<handle_long_opt>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
call   1060 <strlen@plt>
lea    0x3(%rax),%rdi
call   1080 <malloc@plt>
mov    %rax,%rbx
mov    %rax,%rdi
mov    %r14,%rsi
call   1040 <strcpy@plt>
mov    %rbx,%rdi
mov    $0x3d,%esi
call   1070 <strchr@plt>
test   %rax,%rax
je     11aa <handle_long_opt+0x3a>
movb   $0x20,(%rax)
jmp    11cb <handle_long_opt+0x5b>
mov    %rbx,%rdi
mov    $0x20,%esi
call   1070 <strchr@plt>
test   %rax,%rax
jne    11cb <handle_long_opt+0x5b>
lea    0xe3d(%rip),%rsi
mov    %rbx,%rdi
call   1090 <strcat@plt>
mov    %rbx,%rdi
call   1050 <netsnmp_config@plt>
mov    %rbx,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <free@plt>

LLVM IR (-O0):
@.str = [3 x i8] c" 1\00"
define void @handle_long_opt(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
store i8* %0, i8** %2
%5 = load i8*, i8** %2
%6 = call i64 @strlen(i8* %5)
%7 = add nsw i64 %6, 3
%8 = call i8* @malloc(i64 %7)
store i8* %8, i8** %3
%9 = load i8*, i8** %3
%10 = load i8*, i8** %2
%11 = call i32 @strcpy(i8* %9, i8* %10)
%12 = load i8*, i8** %3
%13 = call i8* @strchr(i8* %12, i8 signext 61)
store i8* %13, i8** %4
%14 = load i8*, i8** %4
%15 = icmp ne i8* %14, null
br i1 %15, label %23, label %16
16: ; preds = %1
%17 = load i8*, i8** %3
%18 = call i8* @strchr(i8* %17, i8 signext 32)
%19 = icmp ne i8* %18, null
br i1 %19, label %23, label %20
20: ; preds = %16
%21 = load i8*, i8** %3
%22 = call i32 @strcat(i8* %21, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
br label %29
23: ; preds = %16, %1
%24 = load i8*, i8** %4
%25 = icmp ne i8* %24, null
br i1 %25, label %26, label %28
26: ; preds = %23
%27 = load i8*, i8** %4
store i8 32, i8* %27
br label %28
28: ; preds = %26, %23
br label %29
29: ; preds = %28, %20
%30 = load i8*, i8** %3
%31 = call i32 @netsnmp_config(i8* %30)
%32 = load i8*, i8** %3
%33 = call i32 @free(i8* %32)
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c" 1\00"
define void @handle_long_opt(i8* %0) {
%2 = tail call i64 @strlen(i8* dereferenceable(1) %0)
%3 = add nsw i64 %2, 3
%4 = tail call i8* @malloc(i64 %3)
%5 = tail call i32 @strcpy(i8* %4, i8* %0)
%6 = tail call i8* @strchr(i8* dereferenceable(1) %4, i8 signext 61)
%7 = icmp eq i8* %6, null
br i1 %7, label %8, label %13
8: ; preds = %1
%9 = tail call i8* @strchr(i8* dereferenceable(1) %4, i8 signext 32)
%10 = icmp eq i8* %9, null
br i1 %10, label %11, label %14
11: ; preds = %8
%12 = tail call i32 @strcat(i8* %4, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
br label %14
13: ; preds = %1
store i8 32, i8* %6
br label %14
14: ; preds = %8, %13, %11
%15 = tail call i32 @netsnmp_config(i8* %4)
%16 = tail call i32 @free(i8* %4)
ret void
}