#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 */
double atof(char *);
char *masprintf(char *, double);
scalar_t__ strcmp(char *, char *);
char *strdup(char *);
char *compute_new_edge_length(char *length_as_string) {
  char *result;
  if (0 != strcmp("", length_as_string)) {
    double length = atof(length_as_string);
    result = masprintf("%g", length / 2);
    if (NULL == result)
      return NULL;
  } else {
    result = strdup("");
  }
  return result;
}


x86 assembly (clang, -O0):
<compute_new_edge_length>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rsi
lea    0xeb3(%rip),%rdi
call   1050 <strcmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
je     11b7 <compute_new_edge_length+0x77>
mov    -0x10(%rbp),%rdi
call   1040 <atof@plt>
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  0xe7b(%rip),%xmm1
divsd  %xmm1,%xmm0
lea    0xe78(%rip),%rdi
call   1030 <masprintf@plt>
mov    %rax,-0x18(%rbp)
xor    %eax,%eax
cmp    -0x18(%rbp),%rax
jne    11b2 <compute_new_edge_length+0x72>
movq   $0x0,-0x8(%rbp)
jmp    11cf <compute_new_edge_length+0x8f>
jmp    11c7 <compute_new_edge_length+0x87>
lea    0xe4c(%rip),%rdi
call   1060 <strdup@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<compute_new_edge_length>:
push   %rbx
mov    %rdi,%rbx
lea    0xebf(%rip),%rdi
mov    %rbx,%rsi
call   1050 <strcmp@plt>
test   %rax,%rax
je     117b <compute_new_edge_length+0x3b>
mov    %rbx,%rdi
call   1040 <atof@plt>
mulsd  0xe98(%rip),%xmm0
lea    0xe99(%rip),%rdi
call   1030 <masprintf@plt>
test   %rax,%rax
je     1189 <compute_new_edge_length+0x49>
pop    %rbx
ret
lea    0xe88(%rip),%rdi
call   1060 <strdup@plt>
pop    %rbx
ret
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [1 x i8] zeroinitializer
@.str.1 = [3 x i8] c"%g\00"
define i8* @compute_new_edge_length(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca double
store i8* %0, i8** %3
%6 = load i8*, i8** %3
%7 = call i64 @strcmp(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0), i8* %6)
%8 = icmp ne i64 0, %7
br i1 %8, label %9, label %19
9: ; preds = %1
%10 = load i8*, i8** %3
%11 = call double @atof(i8* %10)
store double %11, double* %5
%12 = load double, double* %5
%13 = fdiv double %12, 2.000000e+00
%14 = call i8* @masprintf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), double %13)
store i8* %14, i8** %4
%15 = load i8*, i8** %4
%16 = icmp eq i8* null, %15
br i1 %16, label %17, label %18
17: ; preds = %9
store i8* null, i8** %2
br label %23
18: ; preds = %9
br label %21
19: ; preds = %1
%20 = call i8* @strdup(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
store i8* %20, i8** %4
br label %21
21: ; preds = %19, %18
%22 = load i8*, i8** %4
store i8* %22, i8** %2
br label %23
23: ; preds = %21, %17
%24 = load i8*, i8** %2
ret i8* %24
}

LLVM IR (-O2):
@.str = [1 x i8] zeroinitializer
@.str.1 = [3 x i8] c"%g\00"
define i8* @compute_new_edge_length(i8* %0) {
%2 = tail call i64 @strcmp(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0), i8* %0)
%3 = icmp eq i64 %2, 0
br i1 %3, label %9, label %4
4: ; preds = %1
%5 = tail call double @atof(i8* %0)
%6 = fmul double %5, 5.000000e-01
%7 = tail call i8* @masprintf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), double %6)
%8 = icmp eq i8* %7, null
br i1 %8, label %13, label %11
9: ; preds = %1
%10 = tail call dereferenceable_or_null(1) i8* @strdup(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
br label %11
11: ; preds = %4, %9
%12 = phi i8* [ %7, %4 ], [ %10, %9 ]
br label %13
13: ; preds = %4, %11
%14 = phi i8* [ %12, %11 ], [ null, %4 ]
ret i8* %14
}