#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*/ err(int, char *);
int /*<<< orphan*/ isdigit(unsigned char);
char *malloc(int);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
void obsolete(char *argv[]) {
  int len;
  char *ap, *p, *start;
  while ((ap = *++argv)) {
    if (ap[0] != '-') {
      if (ap[0] != '+')
        return;
    } else if (ap[1] == '-')
      return;
    if (!isdigit((unsigned char)ap[1]))
      continue;
    len = strlen(ap);
    if ((start = p = malloc(len + 3)) == NULL)
      err(1, "malloc");
    *p++ = '-';
    *p++ = ap[0] == '+' ? 's' : 'f';
    (void)strcpy(p, ap + 1);
    *argv = start;
  }
}


x86 assembly (clang, -O0):
<obsolete>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,%rcx
add    $0x8,%rcx
mov    %rcx,-0x8(%rbp)
mov    0x8(%rax),%rax
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
je     1274 <obsolete+0x124>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2d,%eax
je     11a7 <obsolete+0x57>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2b,%eax
je     11a2 <obsolete+0x52>
jmp    1274 <obsolete+0x124>
jmp    11c2 <obsolete+0x72>
mov    -0x18(%rbp),%rax
movsbl 0x1(%rax),%eax
cmp    $0x2d,%eax
jne    11bd <obsolete+0x6d>
jmp    1274 <obsolete+0x124>
jmp    11c2 <obsolete+0x72>
mov    -0x18(%rbp),%rax
movzbl 0x1(%rax),%edi
call   1030 <isdigit@plt>
cmp    $0x0,%eax
jne    11dd <obsolete+0x8d>
jmp    115c <obsolete+0xc>
mov    -0x18(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%edi
add    $0x3,%edi
call   1070 <malloc@plt>
mov    %rax,-0x20(%rbp)
mov    %rax,-0x28(%rbp)
cmp    $0x0,%rax
jne    1217 <obsolete+0xc7>
mov    $0x1,%edi
lea    0xdee(%rip),%rsi
call   1060 <err@plt>
mov    -0x20(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x20(%rbp)
movb   $0x2d,(%rax)
mov    -0x18(%rbp),%rax
movsbl (%rax),%edx
mov    $0x66,%eax
mov    $0x73,%ecx
cmp    $0x2b,%edx
cmove  %ecx,%eax
mov    %al,%cl
mov    -0x20(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x20(%rbp)
mov    %cl,(%rax)
mov    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%rsi
add    $0x1,%rsi
call   1040 <strcpy@plt>
mov    -0x28(%rbp),%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,(%rax)
jmp    115c <obsolete+0xc>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<obsolete>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    0x8(%rdi),%rbx
test   %rbx,%rbx
je     1212 <obsolete+0xc2>
mov    %rdi,%r15
add    $0x10,%r15
lea    0xe8a(%rip),%r14
mov    $0x73,%ebp
jmp    11b3 <obsolete+0x63>
nopl   (%rax)
movb   $0x2d,0x0(%r13)
cmpb   $0x2b,(%rbx)
mov    $0x66,%eax
cmove  %ebp,%eax
mov    %r13,%rdi
add    $0x2,%rdi
mov    %al,0x1(%r13)
mov    %r12,%rsi
call   1040 <strcpy@plt>
mov    %r13,-0x8(%r15)
mov    (%r15),%rbx
add    $0x8,%r15
test   %rbx,%rbx
je     1212 <obsolete+0xc2>
movzbl (%rbx),%eax
cmp    $0x2d,%al
je     11d0 <obsolete+0x80>
cmp    $0x2b,%al
jne    1212 <obsolete+0xc2>
movzbl 0x1(%rbx),%eax
jmp    11d8 <obsolete+0x88>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movzbl 0x1(%rbx),%eax
cmp    $0x2d,%al
je     1212 <obsolete+0xc2>
movzbl %al,%edi
call   1030 <isdigit@plt>
test   %eax,%eax
je     11a7 <obsolete+0x57>
lea    0x1(%rbx),%r12
mov    %rbx,%rdi
call   1050 <strlen@plt>
lea    0x3(%rax),%edi
call   1070 <malloc@plt>
mov    %rax,%r13
test   %rax,%rax
jne    1180 <obsolete+0x30>
mov    $0x1,%edi
mov    %r14,%rsi
call   1060 <err@plt>
jmp    1180 <obsolete+0x30>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [7 x i8] c"malloc\00"
define void @obsolete(i8** %0) {
%2 = alloca i8**
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
store i8** %0, i8*** %2
br label %7
7: ; preds = %50, %40, %1
%8 = load i8**, i8*** %2
%9 = getelementptr inbounds i8*, i8** %8, i32 1
store i8** %9, i8*** %2
%10 = load i8*, i8** %9
store i8* %10, i8** %4
%11 = icmp ne i8* %10, null
br i1 %11, label %12, label %69
12: ; preds = %7
%13 = load i8*, i8** %4
%14 = getelementptr inbounds i8, i8* %13, i64 0
%15 = load i8, i8* %14
%16 = sext i8 %15 to i32
%17 = icmp ne i32 %16, 45
br i1 %17, label %18, label %26
18: ; preds = %12
%19 = load i8*, i8** %4
%20 = getelementptr inbounds i8, i8* %19, i64 0
%21 = load i8, i8* %20
%22 = sext i8 %21 to i32
%23 = icmp ne i32 %22, 43
br i1 %23, label %24, label %25
24: ; preds = %18
br label %69
25: ; preds = %18
br label %34
26: ; preds = %12
%27 = load i8*, i8** %4
%28 = getelementptr inbounds i8, i8* %27, i64 1
%29 = load i8, i8* %28
%30 = sext i8 %29 to i32
%31 = icmp eq i32 %30, 45
br i1 %31, label %32, label %33
32: ; preds = %26
br label %69
33: ; preds = %26
br label %34
34: ; preds = %33, %25
%35 = load i8*, i8** %4
%36 = getelementptr inbounds i8, i8* %35, i64 1
%37 = load i8, i8* %36
%38 = call i32 @isdigit(i8 zeroext %37)
%39 = icmp ne i32 %38, 0
br i1 %39, label %41, label %40
40: ; preds = %34
br label %7
41: ; preds = %34
%42 = load i8*, i8** %4
%43 = call i32 @strlen(i8* %42)
store i32 %43, i32* %3
%44 = load i32, i32* %3
%45 = add nsw i32 %44, 3
%46 = call i8* @malloc(i32 %45)
store i8* %46, i8** %5
store i8* %46, i8** %6
%47 = icmp eq i8* %46, null
br i1 %47, label %48, label %50
48: ; preds = %41
%49 = call i32 @err(i32 1, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
br label %50
50: ; preds = %48, %41
%51 = load i8*, i8** %5
%52 = getelementptr inbounds i8, i8* %51, i32 1
store i8* %52, i8** %5
store i8 45, i8* %51
%53 = load i8*, i8** %4
%54 = getelementptr inbounds i8, i8* %53, i64 0
%55 = load i8, i8* %54
%56 = sext i8 %55 to i32
%57 = icmp eq i32 %56, 43
%58 = zext i1 %57 to i64
%59 = select i1 %57, i32 115, i32 102
%60 = trunc i32 %59 to i8
%61 = load i8*, i8** %5
%62 = getelementptr inbounds i8, i8* %61, i32 1
store i8* %62, i8** %5
store i8 %60, i8* %61
%63 = load i8*, i8** %5
%64 = load i8*, i8** %4
%65 = getelementptr inbounds i8, i8* %64, i64 1
%66 = call i32 @strcpy(i8* %63, i8* %65)
%67 = load i8*, i8** %6
%68 = load i8**, i8*** %2
store i8* %67, i8** %68
br label %7
69: ; preds = %24, %32, %7
ret void
}

LLVM IR (-O2):
@.str = [7 x i8] c"malloc\00"
define void @obsolete(i8** nocapture %0) {
%2 = getelementptr inbounds i8*, i8** %0, i64 1
%3 = load i8*, i8** %2
%4 = icmp eq i8* %3, null
br i1 %4, label %39, label %5
5: ; preds = %1, %35
%6 = phi i8* [ %37, %35 ], [ %3, %1 ]
%7 = phi i8** [ %36, %35 ], [ %2, %1 ]
%8 = load i8, i8* %6
switch i8 %8, label %39 [
i8 45, label %12
i8 43, label %9
]
9: ; preds = %5
%10 = getelementptr inbounds i8, i8* %6, i64 1
%11 = load i8, i8* %10
br label %16
12: ; preds = %5
%13 = getelementptr inbounds i8, i8* %6, i64 1
%14 = load i8, i8* %13
%15 = icmp eq i8 %14, 45
br i1 %15, label %39, label %16
16: ; preds = %9, %12
%17 = phi i8 [ %11, %9 ], [ %14, %12 ]
%18 = getelementptr inbounds i8, i8* %6, i64 1
%19 = tail call i32 @isdigit(i8 zeroext %17)
%20 = icmp eq i32 %19, 0
br i1 %20, label %35, label %21
21: ; preds = %16
%22 = tail call i32 @strlen(i8* %6)
%23 = add nsw i32 %22, 3
%24 = tail call i8* @malloc(i32 %23)
%25 = icmp eq i8* %24, null
br i1 %25, label %26, label %28
26: ; preds = %21
%27 = tail call i32 @err(i32 1, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
br label %28
28: ; preds = %26, %21
%29 = getelementptr inbounds i8, i8* %24, i64 1
store i8 45, i8* %24
%30 = load i8, i8* %6
%31 = icmp eq i8 %30, 43
%32 = select i1 %31, i8 115, i8 102
%33 = getelementptr inbounds i8, i8* %24, i64 2
store i8 %32, i8* %29
%34 = tail call i32 @strcpy(i8* %33, i8* %18)
store i8* %24, i8** %7
br label %35
35: ; preds = %28, %16
%36 = getelementptr inbounds i8*, i8** %7, i64 1
%37 = load i8*, i8** %36
%38 = icmp eq i8* %37, null
br i1 %38, label %39, label %5
39: ; preds = %5, %12, %35, %1
ret void
}