#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*/ assert(int);
int /*<<< orphan*/ printf(char *, ...);
int semver_clean(char *);
scalar_t__ strcmp(char *, char *);
void test_clean() {
  printf("\n# Test: %s\n", "clean");
  int error;
  char str[] = "1.2.3";
  error = semver_clean(str);
  assert(strcmp(str, "1.2.3") == 0);
  assert(error == 0);
  char str2[] = " 1.@2.3-beta #.alpha+12@34  ";
  error = semver_clean(str2);
  assert(strcmp(str2, "1.2.3-beta.alpha+1234") == 0);
  assert(error == 0);
  printf("OK\n");
}


x86 assembly (clang, -O0):
<test_clean>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
lea    0xeb1(%rip),%rdi
lea    0xeb7(%rip),%rsi
mov    $0x0,%al
call   1030 <printf@plt>
mov    0xeb0(%rip),%eax
mov    %eax,-0xa(%rbp)
mov    0xeaa(%rip),%ax
mov    %ax,-0x6(%rbp)
lea    -0xa(%rbp),%rdi
call   1060 <semver_clean@plt>
mov    %eax,-0x4(%rbp)
lea    -0xa(%rbp),%rdi
lea    0xe8b(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
cmpl   $0x0,-0x4(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
mov    0xe8a(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    0xe87(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    0xe84(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xe82(%rip),%eax
mov    %eax,-0x18(%rbp)
mov    0xe7d(%rip),%al
mov    %al,-0x14(%rbp)
lea    -0x30(%rbp),%rdi
call   1060 <semver_clean@plt>
mov    %eax,-0x4(%rbp)
lea    -0x30(%rbp),%rdi
lea    0xe20(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
cmpl   $0x0,-0x4(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
lea    0xe08(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_clean>:
push   %rbp
push   %r14
push   %rbx
sub    $0x30,%rsp
lea    0xea1(%rip),%rdi
lea    0xea7(%rip),%rsi
xor    %eax,%eax
call   1040 <printf@plt>
movw   $0x33,0xc(%rsp)
movl   $0x2e322e31,0x8(%rsp)
2e
lea    0xe90(%rip),%r14
lea    0x8(%rsp),%rbx
mov    %rbx,%rdi
call   1070 <semver_clean@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
mov    %r14,%rsi
call   1050 <strcmp@plt>
xor    %edi,%edi
test   %rax,%rax
sete   %dil
call   1060 <assert@plt>
xor    %edi,%edi
test   %ebp,%ebp
sete   %dil
call   1060 <assert@plt>
movups 0xe8e(%rip),%xmm0
movups %xmm0,0x1d(%rsp)
movaps 0xe75(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
call   1070 <semver_clean@plt>
mov    %eax,%ebp
lea    0xe33(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strcmp@plt>
xor    %edi,%edi
test   %rax,%rax
sete   %dil
call   1060 <assert@plt>
xor    %edi,%edi
test   %ebp,%ebp
sete   %dil
call   1060 <assert@plt>
lea    0xe1f(%rip),%rdi
call   1030 <puts@plt>
add    $0x30,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [13 x i8] c"\0A# Test: %s\0A\00"
@.str.1 = [6 x i8] c"clean\00"
@__const.test_clean.str = [6 x i8] c"1.2.3\00"
@.str.2 = [6 x i8] c"1.2.3\00"
@__const.test_clean.str2 = [29 x i8] c" 1.@2.3-beta #.alpha+12@34 \00"
@.str.3 = [22 x i8] c"1.2.3-beta.alpha+1234\00"
@.str.4 = [4 x i8] c"OK\0A\00"
define void @test_clean() {
%1 = alloca i32
%2 = alloca [6 x i8]
%3 = alloca [29 x i8]
%4 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%5 = bitcast [6 x i8]* %2 to i8*
%6 = getelementptr inbounds [6 x i8], [6 x i8]* %2, i64 0, i64 0
%7 = call i32 @semver_clean(i8* %6)
store i32 %7, i32* %1
%8 = getelementptr inbounds [6 x i8], [6 x i8]* %2, i64 0, i64 0
%9 = call i64 @strcmp(i8* %8, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%10 = icmp eq i64 %9, 0
%11 = zext i1 %10 to i32
%12 = call i32 @assert(i32 %11)
%13 = load i32, i32* %1
%14 = icmp eq i32 %13, 0
%15 = zext i1 %14 to i32
%16 = call i32 @assert(i32 %15)
%17 = bitcast [29 x i8]* %3 to i8*
%18 = getelementptr inbounds [29 x i8], [29 x i8]* %3, i64 0, i64 0
%19 = call i32 @semver_clean(i8* %18)
store i32 %19, i32* %1
%20 = getelementptr inbounds [29 x i8], [29 x i8]* %3, i64 0, i64 0
%21 = call i64 @strcmp(i8* %20, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0))
%22 = icmp eq i64 %21, 0
%23 = zext i1 %22 to i32
%24 = call i32 @assert(i32 %23)
%25 = load i32, i32* %1
%26 = icmp eq i32 %25, 0
%27 = zext i1 %26 to i32
%28 = call i32 @assert(i32 %27)
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [13 x i8] c"\0A# Test: %s\0A\00"
@.str.1 = [6 x i8] c"clean\00"
@.str.2 = [6 x i8] c"1.2.3\00"
@__const.test_clean.str2 = [29 x i8] c" 1.@2.3-beta #.alpha+12@34 \00"
@.str.3 = [22 x i8] c"1.2.3-beta.alpha+1234\00"
@str = [3 x i8] c"OK\00"
define void @test_clean() {
%1 = alloca [6 x i8]
%2 = alloca [29 x i8]
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%4 = getelementptr inbounds [6 x i8], [6 x i8]* %1, i64 0, i64 0
%5 = call i32 @semver_clean(i8* %4)
%6 = call i64 @strcmp(i8* %4, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%7 = icmp eq i64 %6, 0
%8 = zext i1 %7 to i32
%9 = call i32 @assert(i32 %8)
%10 = icmp eq i32 %5, 0
%11 = zext i1 %10 to i32
%12 = call i32 @assert(i32 %11)
%13 = getelementptr inbounds [29 x i8], [29 x i8]* %2, i64 0, i64 0
%14 = call i32 @semver_clean(i8* %13)
%15 = call i64 @strcmp(i8* %13, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0))
%16 = icmp eq i64 %15, 0
%17 = zext i1 %16 to i32
%18 = call i32 @assert(i32 %17)
%19 = icmp eq i32 %14, 0
%20 = zext i1 %19 to i32
%21 = call i32 @assert(i32 %20)
%22 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @str, i64 0, i64 0))
ret void
}