#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 */
struct job_t {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ atoi(char *);
struct job_t *getjobjid(struct job_t *, int /*<<< orphan*/);
struct job_t *getjobpid(struct job_t *, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, char *);
struct job_t *getjobid(struct job_t *job_list, char *id) {
  struct job_t *job;
  if (id[0] == 37) {
    id++;
    if (!(job = getjobjid(job_list, atoi(id)))) {
      printf("%s: No such job\n", id);
      return NULL;
    }
  } else {
    if (!(job = getjobpid(job_list, atoi(id)))) {
      printf("(%s): No such process\n", id);
      return NULL;
    }
  }
  return job;
}


x86 assembly (clang, -O0):
<getjobid>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x25,%eax
jne    11b8 <getjobid+0x78>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rdi
call   1050 <atoi@plt>
mov    -0x28(%rbp),%rdi
mov    %eax,%esi
call   1060 <getjobjid@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
jne    11b3 <getjobid+0x73>
mov    -0x18(%rbp),%rsi
lea    0xe5f(%rip),%rdi
call   1030 <printf@plt>
movq   $0x0,-0x8(%rbp)
jmp    120c <getjobid+0xcc>
jmp    1204 <getjobid+0xc4>
mov    -0x10(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x18(%rbp),%rdi
call   1050 <atoi@plt>
mov    -0x30(%rbp),%rdi
mov    %eax,%esi
call   1040 <getjobpid@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
jne    11ff <getjobid+0xbf>
mov    -0x18(%rbp),%rsi
lea    0xe24(%rip),%rdi
call   1030 <printf@plt>
movq   $0x0,-0x8(%rbp)
jmp    120c <getjobid+0xcc>
jmp    1204 <getjobid+0xc4>
mov    -0x20(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getjobid>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %rdi,%r14
cmpb   $0x25,(%rsi)
jne    1173 <getjobid+0x33>
add    $0x1,%rbx
mov    %rbx,%rdi
call   1050 <atoi@plt>
mov    %r14,%rdi
mov    %eax,%esi
call   1060 <getjobjid@plt>
test   %rax,%rax
jne    119b <getjobid+0x5b>
lea    0xe8f(%rip),%rdi
jmp    1191 <getjobid+0x51>
mov    %rbx,%rdi
call   1050 <atoi@plt>
mov    %r14,%rdi
mov    %eax,%esi
call   1040 <getjobpid@plt>
test   %rax,%rax
jne    119b <getjobid+0x5b>
lea    0xe80(%rip),%rdi
mov    %rbx,%rsi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.job_t = type { i32 }
@.str = [17 x i8] c"%s: No such job\0A\00"
@.str.1 = [23 x i8] c"(%s): No such process\0A\00"
define %struct.job_t* @getjobid(%struct.job_t* %0, i8* %1) {
%3 = alloca %struct.job_t*
%4 = alloca %struct.job_t*
%5 = alloca i8*
%6 = alloca %struct.job_t*
store %struct.job_t* %0, %struct.job_t** %4
store i8* %1, i8** %5
%7 = load i8*, i8** %5
%8 = getelementptr inbounds i8, i8* %7, i64 0
%9 = load i8, i8* %8
%10 = sext i8 %9 to i32
%11 = icmp eq i32 %10, 37
br i1 %11, label %12, label %24
12: ; preds = %2
%13 = load i8*, i8** %5
%14 = getelementptr inbounds i8, i8* %13, i32 1
store i8* %14, i8** %5
%15 = load %struct.job_t*, %struct.job_t** %4
%16 = load i8*, i8** %5
%17 = call i32 @atoi(i8* %16)
%18 = call %struct.job_t* @getjobjid(%struct.job_t* %15, i32 %17)
store %struct.job_t* %18, %struct.job_t** %6
%19 = icmp ne %struct.job_t* %18, null
br i1 %19, label %23, label %20
20: ; preds = %12
%21 = load i8*, i8** %5
%22 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* %21)
store %struct.job_t* null, %struct.job_t** %3
br label %36
23: ; preds = %12
br label %34
24: ; preds = %2
%25 = load %struct.job_t*, %struct.job_t** %4
%26 = load i8*, i8** %5
%27 = call i32 @atoi(i8* %26)
%28 = call %struct.job_t* @getjobpid(%struct.job_t* %25, i32 %27)
store %struct.job_t* %28, %struct.job_t** %6
%29 = icmp ne %struct.job_t* %28, null
br i1 %29, label %33, label %30
30: ; preds = %24
%31 = load i8*, i8** %5
%32 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i8* %31)
store %struct.job_t* null, %struct.job_t** %3
br label %36
33: ; preds = %24
br label %34
34: ; preds = %33, %23
%35 = load %struct.job_t*, %struct.job_t** %6
store %struct.job_t* %35, %struct.job_t** %3
br label %36
36: ; preds = %34, %30, %20
%37 = load %struct.job_t*, %struct.job_t** %3
ret %struct.job_t* %37
}

LLVM IR (-O2):
%struct.job_t = type { i32 }
@.str = [17 x i8] c"%s: No such job\0A\00"
@.str.1 = [23 x i8] c"(%s): No such process\0A\00"
define %struct.job_t* @getjobid(%struct.job_t* %0, i8* %1) {
%3 = load i8, i8* %1
%4 = icmp eq i8 %3, 37
br i1 %4, label %5, label %12
5: ; preds = %2
%6 = getelementptr inbounds i8, i8* %1, i64 1
%7 = tail call i32 @atoi(i8* %6)
%8 = tail call %struct.job_t* @getjobjid(%struct.job_t* %0, i32 %7)
%9 = icmp eq %struct.job_t* %8, null
br i1 %9, label %10, label %18
10: ; preds = %5
%11 = tail call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* %6)
br label %18
12: ; preds = %2
%13 = tail call i32 @atoi(i8* %1)
%14 = tail call %struct.job_t* @getjobpid(%struct.job_t* %0, i32 %13)
%15 = icmp eq %struct.job_t* %14, null
br i1 %15, label %16, label %18
16: ; preds = %12
%17 = tail call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i8* %1)
br label %18
18: ; preds = %5, %12, %16, %10
%19 = phi %struct.job_t* [ null, %10 ], [ null, %16 ], [ %8, %5 ], [ %14, %12 ]
ret %struct.job_t* %19
}